jgaskins / perpetuity

Persistence gem for Ruby objects using the Data Mapper pattern
http://jgaskins.org/blog/2012/04/20/data-mapper-vs-active-record/
MIT License
250 stars 14 forks source link

JOIN queries #53

Open jgaskins opened 10 years ago

jgaskins commented 10 years ago

All the major SQL and a few NoSQL databases support JOIN queries. Currently, there is nothing in here to support them. Everything is queried like we're doing an ActiveRecord includes to load associated records, but I'd like to support joins:

article_mapper = Perpetuity[Article]
article_mapper.select { |article| article.author.name == 'Jamie' }

The mapper would then look at the author attribute, see that it's a reference to another object, then set up that join. And along with #44, we need a way to indicate that in the intermediate query form.