50 points · by chrismealy · 15y ago · 18 comments
After all the entire point of data-mapper is that your objects don't know the details about how they're stored.
User.where(:active => true).kind_of?(Enumerable)
What's the issue here? If you change it to
User.where(:active => true).all.kind_of?(Enumerable)
In fact, some of Enumerable's messages could even be used to further build the query (e.g. `Enumerable#drop(Integer)` simply bumps the query's offset)
Is there some significant benefit to it returning true for Enumerable that I'm just missing?
My primary need was to be able to map the same models to different schemas, including very badly designed legacy ones, so the mapper layer had to be clearly separated from the model and very hackable. Also, the query syntax had to be powerful enough to avoid SQL whenever possible, so that the same queries could be applied to different environments.
Right now it implements Units Of Work and Identity Mappers; it has deep querying and multilevel strategic loading (not limited to one level as with DataMapper); functions and aggregates; and many other features, wrapped in a familiar easy syntax.
If someone wants to try it, I'd love to hear some feedback: it's at https://github.com/me/spider.
About the raw SQL: Sequel excels at this. And you can combine easily both.
I found the post interesting, but would have loved to see more examples to the arguments. Specially in the frameworks the author gives so much praise.