Problem with associations, again (belongsTo the same table more than 1 time)...

34 views
Skip to first unread message

Alex Purice

unread,
Jul 26, 2011, 3:55:42 PM7/26/11
to ColdFusion on Wheels
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

tpet...@gmail.com

unread,
Jul 26, 2011, 4:48:17 PM7/26/11
to ColdFusion on Wheels
this is actually fixed in new-master (1.2), but i haven't had a chance
to backport it over to the 1.1-release branch (1.1.4).

this is the commit that needs backporting:

https://github.com/cfwheels/cfwheels/commit/d538d63f2df4f6e715f2bba18adbbe037af7e79f

On Jul 26, 3:55 pm, Alex Purice <alexei.pur...@gmail.com> wrote:
> 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/14d8a71c...

Alex Purice

unread,
Jul 26, 2011, 5:11:13 PM7/26/11
to ColdFusion on Wheels
Thanks for the prompt reply!

Would you mind to tell me when you will have a chance to port it to
1.1.x? Is it something a day like thing? Or more of a month like
thing? I'm not rude of any kind, please, I'm asking just because I
stuck in the middle of the task and need to tell my manager what we
will do on it, will postpone the task to a later time or not.


On Jul 26, 11:48 pm, "tpetru...@gmail.com" <tpetru...@gmail.com>
wrote:
> this is actually fixed in new-master (1.2), but i haven't had a chance
> to backport it over to the 1.1-release branch (1.1.4).
>
> this is the commit that needs backporting:
>
> https://github.com/cfwheels/cfwheels/commit/d538d63f2df4f6e715f2bba18...
>

Scott

unread,
Aug 2, 2011, 3:51:11 PM8/2/11
to ColdFusion on Wheels

I have a new project that Im working on that requires multiple
references to the same table. I grabbed the latest 1.2 git but it
appears to still not support table aliases.

Has the plan to support this changed? Any update available?

thanks
scott
Reply all
Reply to author
Forward
0 new messages