Hi there!

I've created a small monkeypatch which optimizes queries to  
associations:

http://pastie.org/306233

In two words:

author.articles.all(...query...) doesn't produce SQL request when all  
articles were loaded: it just filters them using standard ruby  
Array#select/detect/sort methods. #all uses #select, #first uses  
#detect. :order is handled too. :limit/:offset are not supported (yet?)

When articles data is not loaded, this code behaves as usual. That is  
it creates SQL query for author's articles limited and sorted with  
additional query.


PS. Comments around OneToMany::Proxy#first/#all say:
# FIXME: remove when RelationshipChain#get_children can return a  
Collection

This might mean that my patch won't be needed someday. I hope so.


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"DataMapper" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/datamapper?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to