Verify proper sort handling even if HQL query already has ORDER BY a 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 #2862.
This commit is contained in:
Greg L. Turnquist
2023-03-15 09:33:18 -05:00
parent 6e389d79b1
commit 1d69ece2f8

View File

@@ -784,6 +784,15 @@ class HqlQueryTransformerTests {
+ "from foo f", sort)).endsWith("order by f.age desc");
}
@Test // GH-2862
void sortProperlyAppendsToExistingOrderByWithFunction() {
assertThat(createQueryFor(
"select e from SampleEntity e where function('nativeFunc', ?1) > 'testVal' order by function('nativeFunc', ?1)",
Sort.by(Sort.Order.desc("age")))).isEqualTo(
"select e from SampleEntity e where function('nativeFunc', ?1) > 'testVal' order by function('nativeFunc', ?1), e.age desc");
}
private void assertCountQuery(String originalQuery, String countQuery) {
assertThat(createCountQueryFor(originalQuery)).isEqualTo(countQuery);
}