Skip to content

Repository Paged Query - Sort parameter not removed in count query #1191

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

Closed
pirimpeo opened this issue Aug 17, 2021 · 0 comments · Fixed by #1194
Closed

Repository Paged Query - Sort parameter not removed in count query #1191

pirimpeo opened this issue Aug 17, 2021 · 0 comments · Fixed by #1194
Labels
type: bug A general bug

Comments

@pirimpeo
Copy link

Using Spring Data Repository interface with paginated methods, count queries to retrieve the number of total items are executed without removing the sort parameter, causing the following error in response:

[
  {
    "code": 4210,
    "msg": "Expression (<sorting field>) must depend only on group keys or aggregates.",
    "query": "<count query with order by>"
  }
]

Here you can see that the original query is modified to perform the count by removing skip and limit, but not the sort parameter:
https://github.com/spring-projects/spring-data-couchbase/blob/main/src/main/java/org/springframework/data/couchbase/repository/query/CouchbaseQueryExecution.java#L152

Here you can see that the sort order is added even if isCount is true
https://github.com/spring-projects/spring-data-couchbase/blob/main/src/main/java/org/springframework/data/couchbase/core/query/Query.java#L290

@pirimpeo pirimpeo changed the title Repository Paged Query - Sort parameter not removed on count query Repository Paged Query - Sort parameter not removed in count query Aug 17, 2021
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Aug 17, 2021
mikereiche added a commit that referenced this issue Aug 17, 2021
Also creates the query with skip and limit from any Pageable parameter instead of applying it later.
Closes #1191.
@mikereiche mikereiche added type: bug A general bug and removed status: waiting-for-triage An issue we've not yet triaged labels Aug 17, 2021
mikereiche added a commit that referenced this issue Aug 18, 2021
Also creates the query with skip and limit from any Pageable parameter instead of applying it later.
Closes #1191.
@mikereiche mikereiche added this to the 4.3 M3 (2021.1.0) milestone Sep 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug A general bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants