> Is it at all possible to construct a query using Datamapper, that allows one > to use subqueries passed to an order by? > > For example: > > select users.id from users order by (select count(*) from mods where > mods.owner_id = users.id) asc;
So I converted the query into a left out join and fed it through find_by_sql (dm-ar-finders) which at least gets me a collection which is nice: API::Models::User.find_by_sql(['select users.id from users left outer join mods on mods.owner_id = users.id group by users.id order by count(*)']) But it still means resorting to SQL. ken. -- You received this message because you are subscribed to the Google Groups "DataMapper" group. To post to this group, send email to datamapper@googlegroups.com. To unsubscribe from this group, send email to datamapper+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/datamapper?hl=en.