Allow HQL HAVING without enforcing GROUP BY.

Closes #3840
This commit is contained in:
Mark Paluch
2025-04-14 16:48:32 +02:00
parent b8e8121b16
commit a62996f2bb
4 changed files with 30 additions and 2 deletions

View File

@@ -89,8 +89,8 @@ orderedQuery
;
query
: selectClause fromClause? whereClause? (groupByClause havingClause?)? # SelectQuery
| fromClause whereClause? (groupByClause havingClause?)? selectClause? # FromQuery
: selectClause fromClause? whereClause? groupByClause? havingClause? # SelectQuery
| fromClause whereClause? groupByClause? havingClause? selectClause? # FromQuery
;
queryOrder

View File

@@ -597,6 +597,14 @@ class EqlQueryRendererTests {
GROUP BY c.country
HAVING COUNT(c) > 30
""");
assertQuery("""
SELECT COUNT(f)
FROM FooEntity f
WHERE f.name IN ('Y', 'Basic', 'Remit')
AND f.size = 10
HAVING COUNT(f) > 0
""");
}
@Test

View File

@@ -791,6 +791,18 @@ class HqlQueryRendererTests {
""");
}
@Test
void shouldRenderHavingWithFunction() {
assertQuery("""
SELECT COUNT(f)
FROM FooEntity f
WHERE f.name IN ('Y', 'Basic', 'Remit')
AND f.size = 10
HAVING COUNT(f) > 0
""");
}
@Test
void theRest8() {

View File

@@ -598,6 +598,14 @@ class JpqlQueryRendererTests {
GROUP BY c.country
HAVING COUNT(c) > 30
""");
assertQuery("""
SELECT COUNT(f)
FROM FooEntity f
WHERE f.name IN ('Y', 'Basic', 'Remit')
AND f.size = 10
HAVING COUNT(f) > 0
""");
}
@Test