Repository navigation
fix(datamapping): a createAlias path that starts with an alias declared earlier continues the path of that alias - #17105
borinquenkid wants to merge 1 commit into
Conversation
…ed earlier continues the path of that alias Claude-Session: https://claude.ai/code/session_01Dmki4RzWwreEC2GkkyFnvL
🚨 All tests passed but jobs failed 🚨Failed Jobs without Test Failures🏷️ Commit: 63e8e8b Rerun ControlsClick the checkbox to trigger a rerun:
Learn more about TestLens at testlens.app/docs. |
jamesfredley
left a comment
There was a problem hiding this comment.
Requested changes. An alias declared inside a block is not seen by the next alias in that block.
| return associationPath | ||
| } | ||
| String head = associationPath.substring(0, dot) | ||
| for (Query.Criterion criterion in criteria) { |
There was a problem hiding this comment.
An alias named c is declared for children, then c.related is declared, both inside the same and. The second call starts from the root and throws, because c was added to the and and this only looks at the top list. Continue from c.
There was a problem hiding this comment.
@jamesfredley: confirmed. An alias declared inside and, or or not is not seen by a later alias that continues it, and the cause is wider than the lookup: on Hibernate 5 an association criterion with a dotted path inside a block is translated against the root, so fixing the lookup only moves the failure from createAlias to the query (all six block shapes fail that way). Fixing it properly changes how H5 and AbstractDetachedCriteria track aliases, which is too large for a 7.0.x patch release.
Workaround: declare the aliases at the top level and use them inside the block. That works and is covered by the specs in this PR, which is the chain #14647 reported.
The lookup fix itself works on H7 for all eight block shapes (top level, and, or, not, nested, split, outer first, full paths), so it goes to 8.1.x, with the split of the class in #17109.
A path given to
createAliason aDetachedCriteriaor awherequery that starts with an alias declared earlier now continues the path of that alias: aftercreateAlias('children', 'c'), the pathc.relatedischildren.related. Before, such a call failed with aQueryExceptionor with invalid SQL, so no working code changes (Fixes #14647).This is the 7.0.x part of #16890, split out as matrei asked on that pull request: a bug fix with no new API, in
AbstractDetachedCriteriaonly. The rest of #16890 (theMultipleAliasesMappingContextopt-in and the Hibernate 5 builder changes) is not here.DetachedCriteriaAliasChainSpec: four features; the two that join from an earlier alias fail on 7.0.x without the change.grails-datamapping-core(252 tests) andgrails-data-hibernate5-core(691 tests) pass, andcodeStyleis clean.upgrading60x.adoc; a call that failed before now works, and a first segment that is both an alias and a property names the alias.https://claude.ai/code/session_01Dmki4RzWwreEC2GkkyFnvL