-
Notifications
You must be signed in to change notification settings - Fork 235
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
GroupDate doesn't work with Postgresql databases #251
Comments
OK, I found a working query for orders_by_day for my shopping cart application... it varies from your queries a bit... your query form:
my new query form:
This fixes the problem and allows me to elegantly group/select and sum order totals within date ranges for my graphs, as the gem is supposed to do... but within postgresql |
Hey @Tectract, you need to specify an aggregate method like Order.group_by_day(:created_at).count Groupdate's methods behave the same as Active Record's Order.group(:created_at) # same error |
.sum wasn't working for me, which is what I needed. |
@Tectract you can find a possible resolution here: |
Here was my solution for group_by_week, for reference... I looked at your code, this is sort of what I expected to see, lol.
|
Glad you found something that works. |
Hi there!
Great tool, but I ran into issues trying to run it on my postgresql systems.
Order.group_by_day(:created_at)
ActiveRecord::StatementInvalid: PG::GroupingError: ERROR: column "orders.id" must appear in the GROUP BY clause or be used in an aggregate function
It appears this is a quirk of how the .group statement works in postgresql. Any thoughts on how to get around it?
The text was updated successfully, but these errors were encountered: