
chained queries on associations generate redundant queries
Reported by Jamie Macey | January 26th, 2009 @ 05:22 PM
DataMapper finders are supposed to be chainable, so that Model.all(:conditions).all(:conditions).all(:conditions) or equivalent should only perform one query. Additionally, (and I can't find it in the docs) chained finders also have access to class methods, such that Finger.all(...).long (given the above code) still returns a valid chained association.
http://datamapper.org/doku.php?i... suggests that associations should also return chainable finders, which it does. @hand.fingers.all(...) seems to work just fine. However, @hand.fingers.long, which I expect to work, seems to be running two queries - one on just the association (which is never used) and then another when the final chained association is used.
See gist for code that exhibits bug: http://gist.github.com/53037
Comments and changes to this ticket
-
Dan Kubb (dkubb) February 21st, 2009 @ 02:34 AM
- State changed from unconfirmed to resolved
I just ran the attached script with the dm-core/next branch and it passed as expected: both statements executed only one SQL query.
Marking this ticket as resolved.
-
Dan Kubb (dkubb) February 21st, 2009 @ 02:34 AM
- Assigned user set to Dan Kubb (dkubb)
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 »