Hi folks,
I tried to continue in respective topic, but it seems to be closed, so
I will start new one.
I have exactly the same problem Pierre Christen has/had here ->
http://groups.google.com/group/cfwheels/browse_thread/thread/14d8a71c3b884e37/b912d0d89c82d01d?lnk=gst&q=belongsTo#b912d0d89c82d01d
The guy who programmed the web site before me applied Andy Bellenie's
solution of:
-------------------------------------
<cfset belongsTo(name="creator", class="user",
foreignKey="createdBy")>
<cfset belongsTo(name="updater", class="user",
foreignKey="updatedBy")>
<cfset belongsTo(name="signee", class="user", foreignKey="signedBy")>
-------------------------------------
but he (previous programmer) was on 1.0.5 and hadn't "include" in
finders.
I'm on 1.1.4, I have include in finders and I stuck on it.
Following (pseudo) code:
---------------------------------------------------
transaction = model("transaction").findByKey(key=params.key,
include="creator,updater,signee");
---------------------------------------------------
gives me following error:
---------------------------------------------------
[Macromedia][SQLServer JDBC Driver][SQLServer]The objects "users" and
"users" in the FROM clause have the same exposed names. Use
correlation names to distinguish them.
---------------------------------------------------
And Wheels generates following (pseudo) (partial) SQL under the scene:
---------------------------------------------------
SELECT
yada-yada
FROM
transactions
LEFT OUTER JOIN users ON transactions.createdBy =
users.id
LEFT OUTER JOIN users ON transactions.updatedBy =
users.id
LEFT OUTER JOIN users ON transactions.signedBy =
users.id
---------------------------------------------------
Question is - How to tell Wheels to use table aliases, something like:
---------------------------------------------------
SELECT
yada-yada
FROM
transactions
LEFT OUTER JOIN users AS creator ON transactions.createdBy =
creator.id
LEFT OUTER JOIN users AS updater ON transactions.updatedBy =
updater.id
LEFT OUTER JOIN users AS signee ON transactions.signedBy =
signee.id
---------------------------------------------------
Thanks,
Alex