Skip to content

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

Closed
@pirimpeo

Description

@pirimpeo

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions