jamesfredley commented on code in PR #16836:
URL: https://github.com/apache/grails-core/pull/16836#discussion_r4480510049
##########
grails-data-neo4j/core/src/main/groovy/org/grails/datastore/gorm/neo4j/engine/Neo4jQuery.groovy:
##########
@@ -654,6 +662,22 @@ class Neo4jQuery extends Query {
RelationshipUtils.matchForAssociation(association, var, attributes)
}
+ /**
+ * The pattern that holds when the node has a relationship for the
association, or {@code null} when the
+ * property is not an association stored as a relationship. An association
is not a property of the node, so
+ * a null test on it has to look for the relationship and not for a node
property.
+ */
+ private static String associationRelationshipPattern(GraphPersistentEntity
entity, String propertyName, String prefix) {
+ if (entity.isRelationshipEntity()) {
+ return null
+ }
+ PersistentProperty property = entity.getPropertyByName(propertyName)
+ if (property instanceof Association && !(property instanceof Basic)) {
Review Comment:
`isNull('address')` on an embedded component enters this branch because
`Embedded` is an `Association` and is not `Basic`.
`formatAssociationPatternFromExisting` casts `associatedEntity` to
`GraphPersistentEntity`, and an embedded component's entity is not one, so the
query throws before it runs. Embedded values are stored on the node. Leave them
on the property null test.
##########
grails-data-neo4j/core/src/main/groovy/org/grails/datastore/gorm/neo4j/engine/Neo4jQuery.groovy:
##########
@@ -654,6 +662,22 @@ class Neo4jQuery extends Query {
RelationshipUtils.matchForAssociation(association, var, attributes)
}
+ /**
+ * The pattern that holds when the node has a relationship for the
association, or {@code null} when the
+ * property is not an association stored as a relationship. An association
is not a property of the node, so
+ * a null test on it has to look for the relationship and not for a node
property.
+ */
+ private static String associationRelationshipPattern(GraphPersistentEntity
entity, String propertyName, String prefix) {
+ if (entity.isRelationshipEntity()) {
+ return null
+ }
+ PersistentProperty property = entity.getPropertyByName(propertyName)
Review Comment:
A nested `isNull('owner')` is resolved on the root entity. When the root has
an `owner` association and the joined class has a scalar `owner`, `children {
isNull('owner') }` tests the root's relationship on the child node. A child
whose scalar `owner` is set is treated as null, and `isNotNull` drops that row.
Resolve the property on the entity for `prefix`. Keep the relationship test for
an association of that entity.
--
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]