jamesfredley commented on code in PR #16773:
URL: https://github.com/apache/grails-core/pull/16773#discussion_r4385378478


##########
grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/query/ExpressionResolver.java:
##########
@@ -108,8 +114,14 @@ private Expression<?> resolveFromAlias(String alias, 
String subPath) {
             return subPath != null ? getPath((From<?, ?>) aliased, subPath) : 
aliased;
         }
 
-        // 3. If defined but not joined, materialize it on the CURRENT root
+        // 3. If defined but not joined, materialize it on the CURRENT root or 
PARENT context
         if (aliasRegistry.isDefined(alias)) {
+            if (!aliasRegistry.hasLocalDefinition(alias) && context != null && 
context.getParent() != null) {

Review Comment:
   `owner { createAlias('pets', 'p'); eq('p.name', 'Fido') }` records `p` in 
the top-level registry. This delegation then joins `pets` on the outer root, 
not on `owner`. The base resolved it on the association. A nested `eqProperty` 
through an inherited join is dropped the same way, so the subquery is no longer 
correlated.
   
   Materialize the alias in the association that declared it. Please assert 
that query still returns the matching rows and does not throw.



-- 
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]

Reply via email to