Skip to content
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

Pagination doesn't work properly with with sorting #64

Closed
juanyunis opened this issue Oct 22, 2016 · 5 comments
Closed

Pagination doesn't work properly with with sorting #64

juanyunis opened this issue Oct 22, 2016 · 5 comments
Assignees

Comments

@juanyunis
Copy link

The built in pagination method for a Lucid model doesn't work properly when someone try to use it with orderBy.

Example:

const devices = yield Device.query().orderBy('name', 'desc').paginate(1, 10)

Exception:

select count(*) as "total" from "devices" order by "name" desc - column "devices.name" must appear in the GROUP BY clause or be used in an aggregate function

This problem doesn't happen with other method forPage().

@thetutlage
Copy link
Member

Which database client are you using? For example: Mysql, PostgreSQL

@thetutlage thetutlage self-assigned this Oct 30, 2016
@juanyunis
Copy link
Author

PostgreSQL.

@thetutlage
Copy link
Member

Works great with Mysql and other clients except Postgres. I will push a patch for the same soon.

@juanyunis
Copy link
Author

Awesome

thetutlage added a commit that referenced this issue Jul 16, 2017
order by is not required when getting records total inside paginate method, making sure to filter

the orderby clause from the cloned query

Closes #64
@juhguu
Copy link

juhguu commented Jul 18, 2018

I have the same error using SQL Server database.

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

No branches or pull requests

3 participants