#662 ✓resolved
Oleg Andreev

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

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.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

People watching this ticket

Attachments

Pages