Closed GoogleCodeExporter closed 9 years ago
Tested against svn r1105, still broken.
Original comment by culture...@gmail.com
on 3 Nov 2009 at 4:35
I checked out the whole trunk history with git svn and did a bisect. This was
complicated by the first good revision and the latest revision being on opposite
sides of commits which introduced, removed, or updated the following:
1) gettext
2) rails version changes
3) ruby-ldap version changes
4) semantics of the options for has_many
So at each revision, I had to compensate for those factors. I was able to
determine
where the problem was introduced. This is the "first bad commit":
http://ruby-activeldap.googlecode.com/svn/trunk@1021
This is not surprising, since it's the commit that changed the options for
has_many.
Original comment by culture...@gmail.com
on 3 Nov 2009 at 5:51
[deleted comment]
I notice that has_many and has_many :wrap both use the same collect_targets
method.
This appears to be fundamentally incompatible with the option switch for the
non-wrap
case, unless you also impose the same switch on the :wrap case. The existing
tests
never show any problem, because it appears that has_many without :wrap is never
tested with properties that have different names.
With :wrap, collect_targets looks up the wrapped property on the owning class,
finds
a list of targets, and then looks up those targets on the foreign class. It
makes the
assumption that "primary_key" names a property on the foreign class.
Without :wrap, collect_targets looks up the primary key property on the owning
class.
Then it searches for foreign class objects that match, but the attribute it
uses to
search is the same primary key name. The foreign key name is never used.
I recommend that either the option switch be reverted, or :wrap be made to use
:foreign_key so that its logic matches the non-wrap usage.
Original comment by culture...@gmail.com
on 5 Nov 2009 at 4:33
Ah, the tests I wrote were wrong. Deleted. Ignore the tests. Working on a
better patch.
Original comment by culture...@gmail.com
on 5 Nov 2009 at 4:48
As promised, attached, please find a set of patches which:
1) correct the behavior of has_many without :wrap, in the case where the
primary and
foreign key names are not the same
2) causes has_many :wrap to prefer :foreign_key, but allows :primary_key in a
backwards compatible manner
3) includes a test for item 1
Original comment by culture...@gmail.com
on 5 Nov 2009 at 6:16
Attachments:
Thanks for your patch! It includes a test!!!
I've applied your patch with some modifications.
Original comment by kou...@gmail.com
on 7 Nov 2009 at 1:43
Wow golly... I spent half of yesterday and half of today trying to get a
"manager"
relationship to work and was going nuts. I finally chainsawed the code to get
it
working. Was going to post a patch or ask a question and bumped into this...
I kept assuming that something this basic can't be broken for long without an
update.
Maybe a new level should be pushed out.
Thanks!
Original comment by pedz...@gmail.com
on 26 Nov 2009 at 5:41
Original issue reported on code.google.com by
culture...@gmail.com
on 3 Nov 2009 at 12:25