borinquenkid opened a new pull request, #16143:
URL: https://github.com/apache/grails-core/pull/16143
## Summary
- Adds mock-based unit specs for `AbstractDetachedCriteria` (via
`grails.gorm.DetachedCriteria`) and for the reactive
`grails.gorm.rx.DetachedCriteria`, taking both from ~0% to full line/method
coverage without needing a real datastore.
- Fixes two real bugs surfaced while writing the rx specs:
- `buildQueryableCriteria()` cast the built `DetachedCriteria` to
`QueryableCriteria`, but the rx class never implemented that interface, so
every closure-based subquery (`in`, `inList`, `notIn`,
`eqAll`/`gtAll`/`ltAll`/`geAll`/`leAll`, `gtSome`/`geSome`/`ltSome`/`leSome`)
threw a `ClassCastException` at runtime. Fixed with a small `SubqueryAdapter`
that extends the shared `AbstractDetachedCriteria` base directly, since the
reactive class's own `find()`/`list()` return `Observable` and can't coexist
with `QueryableCriteria`'s `T`/`List<T>` signatures on the same type.
- `prepareQuery()` applied fetch strategies (`join`/`select`) twice: once
via `DynamicFinder.applyDetachedCriteria()`, then again via a redundant
hand-rolled loop that also ignored custom `JoinType`s. Removed the dead
duplicate.
- Fixes a handful of definite-assignment/shadowing/raw-`getAt` warnings in
`AbstractDetachedCriteria` (uninitialized `prop` in `createAlias`, a local
variable named `criteria` shadowing the instance field of the same name in
`clone()`, and negative-index `List` access replaced with `getLast()`).
## Test plan
- [x] `:grails-datamapping-core:test` — 71 new tests in
`AbstractDetachedCriteriaSpec`, all pass
- [x] `:grails-datamapping-rx:test` — 45 new tests across
`DetachedCriteriaSpec` and `DetachedCriteriaQuerySpec`, all pass
- [x] `:grails-datamapping-core:codeStyle` and
`:grails-datamapping-rx:codeStyle` clean
- [x] Verified via `jacocoTestReport` that `AbstractDetachedCriteria` and
`grails.gorm.rx.DetachedCriteria` (plus its new `SubqueryAdapter`) are at ~100%
line/method coverage
🤖 Generated with [Claude Code](https://claude.com/claude-code)
--
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]