Skip to content
This repository has been archived by the owner on Apr 17, 2018. It is now read-only.

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

Open
PolarFox opened this issue Apr 20, 2011 · 1 comment
Open

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

PolarFox opened this issue Apr 20, 2011 · 1 comment

Comments

@PolarFox
Copy link

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
Copy link
Member

tpitale commented Jun 27, 2011

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])

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants