Repository navigation
fix(datamapping-core): a static field holding a chain of where queries keeps every query - #17214
Draft
borinquenkid wants to merge 2 commits into
Draft
borinquenkid wants to merge 2 commits into
borinquenkid wants to merge 2 commits into
Conversation
…s keeps every query
A static field or property holding Author.where { }.where { } kept only the last query, on the class that holds the
field. The first query of the chain becomes the criteria the others add to, on the class it names, and the value is
cast to the type of the field for static type checking.
Claude-Session: https://claude.ai/code/session_01Dmki4RzWwreEC2GkkyFnvL
borinquenkid
requested review from
codeconsole,
jamesfredley,
jdaugherty,
matrei and
sanjana2505006
November 28, 2026 23:55
This was referenced Nov 28, 2026
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stacked on #17184, which it needs. Part of #17212.
Problem
A static field or property of a domain class that holds a chain of
wherequeries kept only the last one, and built it on the class that holds the field:Change
The first query of a chain of
whereandwhereLazycalls, from a class it names or unqualified, becomes the criteria the others add to. The field holds the whole chain, as a method does, and the class still loads without a datastore. The value is cast to the type of the field, which static type checking needs. A field is visited more than once, so a built chain is marked.Chains with another call in them, such as
maxorwhereAny, and chains that start from a stored criteria, still lose queries; #17212 stays open for them.Results that change
A static field or property holding such a chain now returns the rows of the whole chain, on the class the first query names. To keep the previous result, write only the last query on the holding class. No setting: the old behaviour dropped queries the source writes and ran against a class it does not name. The upgrade note and the upgrade skill say so.
Tests
WhereQueryStaticFieldChainSpecruns the chains in a static field and a static property, dynamic and statically compiled. All 103 cases fail without the change, and 66 fail without the cast.grails-datamapping-core,grails-datamapping-core-test, the Hibernate 5 module, the MongoDB module andcodeStylepass.https://claude.ai/code/session_01Dmki4RzWwreEC2GkkyFnvL