lib/redgraph/graph/node_methods.rb in redgraph-0.1.4 vs lib/redgraph/graph/node_methods.rb in redgraph-0.2.0
- old
+ new
@@ -66,10 +66,12 @@
#
def count_nodes(label: nil, properties: nil)
node = Node.new(label: label, properties: properties)
cmd = "MATCH #{node.to_query_string} RETURN COUNT(node)"
- query(cmd).flatten[0]
+ # RedisGraph bug: if there are no matches COUNT returns zero rows
+ # https://github.com/RedisGraph/RedisGraph/issues/1455
+ query(cmd).flatten[0] || 0
end
private
# Builds a Node object from the raw data