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 3d39d6e811
commit fd914b7b5c
4 changed files with 30 additions and 2 deletions

View File

@@ -87,8 +87,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

@@ -603,6 +603,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

@@ -622,6 +622,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

@@ -604,6 +604,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