Reputation: 1637
Using the below Cypher I am trying to get all Zones that are not deleted and their items. The issue here is that the where clause doesn't seem to work at all. It still returns all zones, although some of them are deleted. Any idea what I am missing?
Match(n:Zone)
WITH n
WHERE NOT n.deleted in [NULL, 'false']
OPTIONAL Match(n)-[]-(items:Item)
RETURN n, items;
Using version 2.3.1
Upvotes: 2
Views: 498
Reputation: 11216
I think you cannot deal with nulls with the IN
predicate. I think you need to re-craft this with (n.deleted = false or n.deleted is null)
. Also, re-ordering the WITH
would limit the number of zones you return from the database.
MATCH (n:Zone)
WHERE NOT coalesce(n.deleted, false) = false
WITH n
OPTIONAL MATCH (n)--(items:Item)
RETURN n, items;
Upvotes: 3