quarkus
quarkus copied to clipboard
Exception in panache, when using newline before `from`
Describe the bug
I have an application, made with Hibrnate reactive and Panache. I run find
method for HQL query with a new-line character before FROM
clause. The operation fails with an exception.
Expected behavior
New lines in query should not affect the result
Actual behavior
An exception is thrown
How to Reproduce?
- Clone the reporducer:
git clone [email protected]:fedinskiy/reproducer.git -b reproducer/hibernate-newline
- Start a DB in a separate terminal:
docker run \
-e POSTGRESQL_USER=user \
-e POSTGRESQL_PASSWORD=user \
-e POSTGRESQL_DATABASE=mydb \
-e POSTGRES_USER=user \
-e POSTGRES_PASSWORD=user \
-e POSTGRES_DB=mydb \
-p 5432:5432 \
docker.io/library/postgres:15
- run the reproducer:
mvn quarkus:dev
- Try to access the endpoint:
$ curl http://localhost:8080/library/by-author/Dlugi
{"code":500,"error":"begin 7, end -1, length 101"}
- edit file
src/main/java/io/quarkus/ts/hibernate/reactive/http/PanacheEndpoint.java
, add a space between\n
and "FROM" on line 119 6.$ curl http://localhost:8080/library/by-author/Dlugi [{"title":"Slovník"}]
Output of uname -a
or ver
6.7.3-200.fc39.x86_64
Output of java -version
21.0.1, vendor: Eclipse Adoptium
GraalVM version (if different from Java)
No response
Quarkus version or git rev
3.7.1
Build tool (ie. output of mvnw --version
or gradlew --version
)
Apache Maven 3.9.6 (bc0240f3c744dd6b6ec2920b3cd08dcc295161ae)
Additional information
See https://github.com/quarkusio/quarkus/issues/29838 for a similar bug
/cc @FroMage (panache), @loicmathieu (panache)
This has been fixed by #31419
@loicmathieu I can reproduce it even on the latest(3.7.1) Quarkus version. The issue should be reopened.
Which module exactly are you using?
@FroMage do you mean extension? The reproduced, same as before, uses quarkus-reactive-pg-client
, quarkus-hibernate-orm-panache-common
, quarkus-hibernate-reactive
and quarkus-hibernate-reactive-panache
OK, so this is with HR/Panache, whereas https://github.com/quarkusio/quarkus/pull/31419 only tested this with Kotlin and ORM/Panache, so it's possible that the fix is missing in HR/Panache, reopening.
I can reproduce on all releases and even main
. I don't think this was fixed by #31419, nor by my current work on queries, no matter how much I improved them.
This was probably fixed for ORM in #29851 but not for HR.
I'll get to fixing it and making sure we test this.
This is actually all sorts of broken.
I tried to pass this job on to ORM, which now supports projections without new
in the HQL query, exactly as we do, and this reveals that we've had tests that relied on doing a count query for projections that had distinct
results for more than one column, which is not supported for count
. This used to work because we mistakenly dropped the distinct
keyword from the count query.