cancel
Showing results for 
Search instead for 
Did you mean: 

All predicate returning true on empty list in cypher

jrsperry
Node

While debugging some generated cypher queries from graphql, I realized that the all predicate may not be working as expected. Below is a much simpler query to demonstrate my point.

with [] as sample_list return all(b in sample_list where b) - this returns true

3X_d_9_d9c293695e8d034850953c983b9a1553aa2a71bd.png

This appears to conflict with the following from neo4j documention on the all predicate:

"The function all() returns true if the predicate holds for all elements in the given list. null is returned if the list is null or all of its elements are null." - link

Is this desired behavior? Or is the all predicate not working properly since the list is null?

Neo4j version: 4.2.5
Browser: 4.2.6

1 REPLY 1

I think it's working correctly. All elements (zero) are true.

I guess all(x in [] WHERE true) == none(x in [] where true)