
Incorrect SQL generated in association
Reported by bluepojo | July 16th, 2010 @ 03:54 PM
I am building on an existing database trying to set up associations for the existing tables.
In one case I have:
Foo has one Bar
the primary key in Bar is called "status", which is an integer
I want to say:
class Foo
has 1, :bar, :child_key => [:status]
end
This results in the following SQL when Foo.last.bar is called,
for example:
SELECT "STATUS", "SDESCRIP", "STATUS" FROM "BAR" WHERE ("STATUS" =
:1) ORDER BY "STATUS"
Due to having STATUS duplicated, this throws an "ambiguous column naming in select list" error. I am using the Oracle adapter.
Is this a bug, or is there a way to keep the same column from being generated twice by DataMapper?
Comments and changes to this ticket
-
bluepojo July 16th, 2010 @ 03:57 PM
I suppose DataMapper doesn't like it when I have the id specified in the child model?
-
bluepojo July 16th, 2010 @ 04:03 PM
Disregard my last comment, it doesn't make sense to me either. :P
-
wwhwpcd October 12th, 2010 @ 07:34 PM
Definitely a bug. Workaround is to specify some other order or even :order => nil
-
Martin Gamsjaeger (snusnu) October 29th, 2010 @ 03:05 PM
- State changed from new to unconfirmed
I just tried to reproduce this and couldn't. Have a look at this pastie, it shows what i used to test. If you still see a bug, please link to a pastie I can use to reproduce the behavior you see.
-
Piotr Solnica (solnic) March 24th, 2011 @ 05:58 AM
- State changed from unconfirmed to not-applicable
This seems to be working correctly. I'm marking as not-applicable, please re-open if you still can reproduce the problem
Please Sign in or create a free account to add a new ticket.
With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »