opencypher / cypher-for-gremlin

Cypher for Gremlin adds Cypher support to any Gremlin graph database.
Apache License 2.0
359 stars 48 forks source link

CASE in WITH works is incorrect if some property empty #279

Closed mad closed 5 years ago

mad commented 5 years ago

Example of graph

        graph.traversal()
             .addV("Org").property("Name", "Org1").as("org")
             .addV("Person").property("Name", "Foo").as("p1")
             .addV("Person").property("Name", "Boo").as("p2")
             .addV("Person").property("Name", "Woo").as("p3")
             .addE("E").from("org").to("p1").property("e", true)
             .addE("E").from("org").to("p2").property("e", false)
             .addE("E").from("org").to("p3")
             .iterate();

Query 1:

MATCH (n:Org)-[r]-(p:Person)
WHERE id(n) IN [{nID}]
WITH p.Name as Name, CASE r.e WHEN true THEN 'Yes' WHEN false THEN 'No' ELSE r.e END AS Work
RETURN Name, Work

Expected:

[{Name=Foo, Work=Yes}, {Name=Boo, Work=No}, {Name=Woo, Work=null}]

Actual:

[{Name=Foo, Work=Yes}, {Name=Boo, Work=No}]

Query 2:

MATCH (n:Org)-[r]-(p:Person)
WHERE id(n) IN [{nID}]
RETURN p.Name as Name, CASE r.e WHEN true THEN 'Yes' WHEN false THEN 'No' ELSE r.e END AS Work

Work is correct:

[{Name=Woo, Work=null}, {Name=Boo, Work=No}, {Name=Foo, Work=Yes}]
dwitry commented 5 years ago

Fix pushed to tinkerpop334 as well.