Skip to content

Assert in the TCK that where-query closures are rewritten into criteria - #16825

Closed
borinquenkid wants to merge 10 commits into
fix/gorm-aggregate-subquery-8.0.xfrom
fix/tck-where-ast-8.0.x
Closed

borinquenkid wants to merge 10 commits into
fix/gorm-aggregate-subquery-8.0.xfrom
fix/tck-where-ast-8.0.x

Conversation

@borinquenkid

Copy link
Copy Markdown
Member

Fixes #16810

Stacked on #16824 (chain: #16816, #16817, #16818, #16820, #16821, #16822, #16823, #16824). no ci until the chain reaches 8.0.x.

What I found

The issue says the TCK sources are compiled without the where-query AST transformation. On 8.0.x they are not:

  • grails-datamapping-tck has grails-datamapping-core on its compile classpath (api project(':grails-datamapping-core')), which carries the GlobalDetachedCriteriaASTTransformation service entry.
  • The compiled closure of WhereQueryIssueVerificationSpec calls isNull("bar"): bar == null was rewritten into a criterion.
  • That spec already asserts counts that only hold when the rewrite happened (untransformed, the closure builds no criterion and where { bar == null }.count() returns every row, not 0).
  • I scanned the TCK and grails-datamapping-core-test for where closures inside Spock then: and expect: blocks, where Spock's condition rewriting runs before the where transformation and drops the criterion. There are none.

So no build change is needed. The risk the issue describes is real if the dependency is ever lost, so this PR adds an explicit guard.

Changes

WhereTransformAppliedSpec (TCK, runs in every datastore module) reads the criteria a where query holds: bar == null is IsNull, bar != null is IsNotNull, and ==, !=, >, < with a value are Equals, NotEquals, GreaterThan, LessThan on bar with that value. It also checks the criteria exist when the query is declared, before any datastore call.

Tests

7 tests, passing on MongoDB, Neo4j and Hibernate 7. codeStyle, validateRepositoryConventions and rat pass. No production code changes.

WhereTransformAppliedSpec reads the criteria a where query holds, so a TCK
build that loses the where-query AST transformation fails by name instead of
passing on results alone.

Fixes #16810
Copilot AI balanced review requested due to automatic review settings November 2, 2026 02:04

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@borinquenkid

Copy link
Copy Markdown
Member Author

Replaced by #16876, which has only this change on 8.0.x. This branch sat on top of the chain #16816 to #16824, so its diff against 8.0.x was the whole chain. Closing; the review history here was Copilot's only.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants