Page count fails when using a sort specification in a Panache query with a SELECT DISTINCT statement in Quarkus 3.17 #44960
Labels
area/panache
kind/bug-thirdparty
Bugs that are caused by third-party components and not causing a major dysfunction of core Quarkus.
Describe the bug
Given a JPA entity like
ExampleEntity
then trying to determine the number of available pages with the
pageCount()
method fails when the paginatedPanacheQuery
was created with a sort specification and uses aSELECT DISTINCT
statement:Invoking the
pageCount()
method results in anSQLGrammarException
when using a PostgreSQL database:The above code worked up until Quarkus 3.16.4, we are only seeing this type of error with the 3.17 release line.
Looking at the generated SQL I understand why this isn't working, but knowing this worked for all major version
3
release lines so far I'm wondering whether we should assume this is a bug and thepageCount()
method should drop theORDER BY
expression or whether this should have never worked in the first place and we should change our code here to call thepageCount()
only on Panache queries where no sort specification was defined.Expected behavior
The
pageCount()
ignores the sort specification and correctly returns the number of available pages.Actual behavior
An
org.hibernate.exception.SQLGrammarException
statingERROR: for SELECT DISTINCT, ORDER BY expressions must appear in select list
.How to Reproduce?
See example above.
Output of
uname -a
orver
Darwin Kernel Version 24.1.0
Output of
java -version
openjdk version "21.0.5" 2024-10-15 LTS
Quarkus version or git rev
3.17
Build tool (ie. output of
mvnw --version
orgradlew --version
)Gradle 8.11.1
Additional information
No response
The text was updated successfully, but these errors were encountered: