quarkus icon indicating copy to clipboard operation
quarkus copied to clipboard

Exception in panache, when using newline before `from`

Open fedinskiy opened this issue 2 years ago • 8 comments

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?

  1. Clone the reporducer: git clone [email protected]:fedinskiy/reproducer.git -b reproducer/hibernate-newline
  2. 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
  1. run the reproducer: mvn quarkus:dev
  2. Try to access the endpoint:
$ curl http://localhost:8080/library/by-author/Dlugi
{"code":500,"error":"begin 7, end -1, length 101"}
  1. 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

fedinskiy avatar Feb 13 '23 11:02 fedinskiy

/cc @FroMage (panache), @loicmathieu (panache)

quarkus-bot[bot] avatar Feb 13 '23 11:02 quarkus-bot[bot]

This has been fixed by #31419

loicmathieu avatar Mar 16 '23 17:03 loicmathieu

@loicmathieu I can reproduce it even on the latest(3.7.1) Quarkus version. The issue should be reopened.

fedinskiy avatar Feb 08 '24 15:02 fedinskiy

Which module exactly are you using?

FroMage avatar Feb 09 '24 10:02 FroMage

@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

fedinskiy avatar Feb 09 '24 11:02 fedinskiy

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.

FroMage avatar Feb 12 '24 11:02 FroMage

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.

FroMage avatar Feb 15 '24 10:02 FroMage

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.

FroMage avatar Feb 15 '24 14:02 FroMage