monetschemist opened a new issue, #14569:
URL: https://github.com/apache/grails-core/issues/14569
The count() method of detached criteria / where gives incorrect results when
a projection is used in the where {}. In fact it appears that
detachedCriteria.count() returns the same value as the first returned
projection count.
### Steps to Reproduce
This query
```
def c = gtest01.TestA.where {
projections {
groupProperty 'grouping'
count()
}
}
c.list().each { t ->
println "t $t"
}
println c.count()
```
produces the following result:
```
t [1, 12]
t [2, 16]
t [3, 9]
t [4, 18]
t [5, 5]
t [6, 20]
t [7, 13]
t [8, 7]
12
```
Note that there are 8 results returned, not 12 as indicated by count(); and
that the value returned by count is the same as the value of count() in the
first result from the projection (this is consistent across three separate
cases I have tried).
### Expected Behaviour
As noted above, detachedCriteria.count() in the above example should return
8.
### Actual Behaviour
Instead, detachedCriteria.count() in the above example returns 12, which
appears to be the same value as the count returned from the first projection /
grouping result.
### Environment Information
- **Operating System**: Linux 4.13.0-41-generic
apache/grails-data-mapping#46-Ubuntu SMP Wed May 2 13:38:30 UTC 2018 x86_64
x86_64 x86_64 GNU/Linux
- **GORM Version:** 6.1.9.RELEASE
- **Grails Version (if using Grails):** 3.3.5
- **JDK Version:** 1.8.0_171
### Example Application
https://github.com/monetschemist/grails-where-count-problem
--
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]