Skip to content

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

Merged
jdaugherty merged 1 commit into
8.0.xfrom
fix/tck-where-ast-standalone-8.0.x
Nov 6, 2026
Merged

jdaugherty merged 1 commit into
8.0.xfrom
fix/tck-where-ast-standalone-8.0.x

Conversation

@borinquenkid

Copy link
Copy Markdown
Member

Fixes #16810

Replaces #16825, which sat on top of a chain of PRs. This branch has only this change, on 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 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.

@jdaugherty
jdaugherty merged commit e045f87 into 8.0.x Nov 6, 2026
49 checks passed
@jdaugherty
jdaugherty deleted the fix/tck-where-ast-standalone-8.0.x branch November 6, 2026 13:09

@jamesfredley jamesfredley 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.

The TCK assertions match the existing where-query transformer. Null comparisons become isNull and isNotNull, and value comparisons map to the matching criteria. No production code changes.

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.

TCK: Wire where-query AST transformation for criteria test suites

4 participants