Skip to content

order by clause is not removed from derived count query when newline after the order by clause [DATAJPA-1500] #1813

@spring-projects-issues

Description

@spring-projects-issues

Jean-Baptiste Nizet opened DATAJPA-1500 and commented

When the query of a Query annotation ends with an order by clause, it's normally removed from the derived count query used for pagination. But that doesn't happen if there is a newline character after the order by clause.

It might sounds weird to have newlines after the end of a query, but it's not at all when using Kotlin multi-line strings to define the query, such as in the following example, which uses the default formatting suggested by IntelliJ when using multiline strings.

@Query(value = """
  select foo from Foo foo
  where foo.bar = :bar
  order by foo.name
""")

The issue seems to be the pattern ORDER_BY, used at the end of the method createCountQueryFor of QueryUtils


Affects: 2.1.4 (Lovelace SR4)

Referenced from: pull request #380

Backported to: 2.1.9 (Lovelace SR9), 1.11.23 (Ingalls SR23)

Metadata

Metadata

Assignees

Labels

in: coreIssues in core supporttype: bugA general bug

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions