Skip to content

using PanacheQuery#project with multi-line string in Kotlin fails #31210

@bard-kristian

Description

@bard-kristian

Describe the bug

This line checks if the query starts with select (note the trailing space), but in Kotlin you normally use (I do at least) this type of string for queries

val hql = """
    select myStuff
    and do more hql stuff here
""".trimIndent()

which doesn't have the trailing space that's checked for unless you manually add one. Instead theres a \n after select. This in turns messes with the generated HQL when you use io.quarkus.hibernate.orm.panache.kotlin.PanacheQuery#project since it will insert its own select at the beginning if it's missing (if I've understood everything correctly).

EDIT: I thought these strings were a Kotlin feature, but it seems it's a Java feature ref https://docs.oracle.com/en/java/javase/15/text-blocks/index.html

Expected behavior

That text blocks work with .project().

Actual behavior

Using text blocks do not work .project() when generating the HQL for .project() since Quarkus looks for select with the space to see if we supplied our own select.

How to Reproduce?

See the reproducer.

Output of uname -a or ver

No response

Output of java -version

No response

GraalVM version (if different from Java)

No response

Quarkus version or git rev

Discovered in 2.16.0.Final, reproducer is 2.16.3.Final

Build tool (ie. output of mvnw --version or gradlew --version)

No response

Additional information

panache-project-reproducer.zip

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions