#785 ✓resolved
Jamie Macey

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

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

Pages