borinquenkid opened a new issue, #16584:
URL: https://github.com/apache/grails-core/issues/16584

   ## Summary
   
   In GORM for Neo4j, `isNull` on an association property is compiled to a test 
on a node property, but an association is stored as a relationship, so the 
condition is always true and matches every node.
   
   ## Where
   
   `Neo4jQuery` 
(`grails-data-neo4j/core/src/main/groovy/org/grails/datastore/gorm/neo4j/engine/Neo4jQuery.groovy`),
 the `Query.IsNull` handler:
   
   ```groovy
   return new CypherExpression("${entity.formatProperty(prefix, 
criterion.property)} IS NULL")
   ```
   
   For `isNull('parent')` this yields `n.parent IS NULL`. `parent` is a 
relationship, not a property of the node, so it is never set and the test is 
true for every node.
   
   ## Reproduction
   
   ```groovy
   class Folder {
       String name
       Folder parent
       static constraints = { parent nullable: true }
   }
   
   Other = new Folder(name: 'Other').save(flush: true)
   new Folder(name: 'Root', parent: Other).save(flush: true)
   
   Folder.createCriteria().list { isNull('parent') }
   ```
   
   Expected: only `Other`. Actual: both folders.
   
   It surfaced in the TCK spec `UniqueConstraintNullGroupValueSpec` (PR #16583, 
for #14503): a `unique` constraint grouped on a null association validates 
through `isNull`, so a top level folder is reported as a duplicate of a folder 
of the same name under a parent. That feature is marked `@PendingFeatureIf` on 
Neo4j until this is fixed; it will start failing as pending once it passes, 
which is the cue to remove the marker.
   
   ## Expected
   
   `isNull` / `isNotNull` on an association should test for the absence / 
presence of the relationship.
   


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