Skip to content

ORDER BY is wrongly handled for JPA queries for native database functions #2862

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
gregturn opened this issue Mar 15, 2023 · 1 comment
Closed
Assignees
Labels
in: query-parser Everything related to parsing JPQL or SQL

Comments

@gregturn
Copy link
Contributor

gregturn commented Mar 15, 2023

another case where a workaround is not as trivial as when using native database functions:

select e from SampleEntity e 
where function('nativeFunc', ?1) > 'testVal' 
order by function('nativeFunc', ?1)

spring data will add extra order by as it incorrectly resolves subsequent function presence as subquery or window query.

Originally posted by @lith-imad in #2620 (comment)

@gregturn gregturn self-assigned this Mar 15, 2023
@gregturn gregturn added the in: query-parser Everything related to parsing JPQL or SQL label Mar 15, 2023
@gregturn
Copy link
Contributor Author

This patch simply adds a test case proving that the query parser properly handles sorts despite an already-existing order by function().

@gregturn gregturn added this to the 3.1 M3 (2023.0.0) milestone Mar 15, 2023
klajdipaja pushed a commit to klajdipaja/spring-data-jpa that referenced this issue Mar 24, 2023
…native function.

Introduce test case proving that apply a Sort to an HQL query with an already-existing "order by function()" is handled properly.

Resolves spring-projects#2862.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: query-parser Everything related to parsing JPQL or SQL
Projects
None yet
Development

No branches or pull requests

1 participant