datamapper / dm-aggregates

DataMapper plugin providing support for aggregates on collections
http://datamapper.org/
MIT License
16 stars 15 forks source link

Aggregate doesn't work with :fields=>[] #2

Open PolarFox opened 13 years ago

PolarFox commented 13 years ago

I did this: Point.all(:fields=> [:player_id], :unique=> true, :order=>[:player_id.asc]).aggregate(:player_id.count) was trying to get : "SELECT COUNT(player_id) FROM points WHERE deleted_at IS NULL GROUP BY :player_id ORDER BY player_id" ended up with: "SELECT COUNT("player_id") FROM "points" WHERE "deleted_at" IS NULL" in log

tpitale commented 13 years ago

To do this for now, use :fields in the aggregate like so:

Point.aggregate(:player_id.count, :fields => [:player_id], :unique => true, :order => [:player_id.asc])