borinquenkid opened a new issue, #15789:
URL: https://github.com/apache/grails-core/issues/15789

   ### Summary
   On MongoDB, a count dynamic finder over an OR disjunction (e.g. 
`countByTypeOrName`) under-counts: it returns a single branch's count instead 
of the distinct union.
   
   ### Reproduce
   `grails-data-mongodb` `DisjunctionQuerySpec`:
   
   ```groovy
   Pet.countByTypeOrName(dogType, 'Jack') == 3   // actually returns 1
   ```
   
   The test data has 3 pets matching `type == dog OR name == 'Jack'`. The 
equivalent **list** query is correct:
   
   ```groovy
   Pet.findAllByTypeOrName(dogType, 'Jack').size() == 3   // passes
   ```
   
   So the query/criteria are correct — only the **count aggregation** over the 
disjunction is wrong. The MongoDB count uses a `$group { _id: 1, count: { $sum: 
1 } }` aggregation.
   
   ### Not a regression
   This is pre-existing, independent of the GormRegistry O(M+N) work: 
`MongoQuery` (the count executor) is byte-identical to before that rewrite, the 
`CountByFinder` count mechanism is equivalent, and find-over-OR works.
   
   ### Status
   `DisjunctionQuerySpec > "Count all dogs or pets with the name Jack"` is 
marked `@PendingFeature` so it does not block the GormRegistry PR; this issue 
tracks the independent fix.
   
   Related historical tracker: GPMONGODB-380.
   


-- 
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