jdaugherty commented on code in PR #16520:
URL: https://github.com/apache/grails-core/pull/16520#discussion_r4185621287


##########
grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/query/HibernateQuery.java:
##########
@@ -539,7 +546,7 @@ public Number countResults() {
 
             countQuery.from(innerSubquery);
             countQuery.select(cb.count(cb.literal(1)));
-            result = (Number) 
getHibernateQueryExecutor().singleResult(getCurrentSession(), countQuery, 
creator.getParameterValues());
+            result = (Number) 
getCountQueryExecutor().singleResult(getCurrentSession(), countQuery, 
creator.getParameterValues());

Review Comment:
   This change also fixes the projection branch, but the new assertions in 
`DetachedCriteriaJoinSpec` only exercise the plain-count branch above. On 8.0.x 
a grouped count with any offset returned `null` here:
   
   ```groovy
   new DetachedCriteria(CountItem).build { projections { groupProperty 
'itemGroup' } }.max(2).offset(1).count()
   // 8.0.x: null, this PR: 5 (the number of groups)
   ```
   
   Could you add a feature to `DetachedCriteriaCountSpec` asserting that a 
grouped count with `max`/`offset` still returns the number of groups, including 
an offset past the number of groups?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to