
assoc#first finder with query ignores parent query
Reported by Oleg Andreev | November 19th, 2008 @ 05:31 AM
Failing regression spec reveals the issue (for the sam's clone):
http://github.com/oleganza/dm-co...
The root of the problem is that :first finder is treated in a special way throughout the codebase. In Proxy class, in Relationship and AbstractAdapter (well, AA is not so DRY, but the problem lays between OneToMany::Proxy and Relationship)
Example: relationship.rb:~92: return collection unless collection.kind_of?(Collection) && collection.any?
My suggestion is to refactor all finders so that :first is not processed in a special way inside Relationship and other lower-level classes. Only top-level #first method should query :all records in the current collection context with the appropriate :limit option and array brackets "stripped off" before returning data to the user (i.e. return results[0])
This should fix the bug and clean up the code.
Comments and changes to this ticket
-
Dan Kubb (dkubb) January 8th, 2009 @ 05:10 AM
- State changed from new to accepted
- Assigned user changed from Sam Smoot to Dan Kubb (dkubb)
-
Jonathan Stott (namelessjon) February 22nd, 2009 @ 03:21 PM
- Tag changed from association, associations, bug, dm-core, finder, sel, spec, tests to association, associations, bug, dm-core, finder, one_file_test, sel, spec, tests
- State changed from accepted to resolved
Resolved as of 0.10.0, see attached one file test.
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 »