thatdot / quine

Quine • a streaming graph • https://quine.io • Discord: https://discord.gg/GMhd8TE4MR
https://quine.io
Other
301 stars 40 forks source link

Cypher: fix asymmetric `Or` branches from `Merge` #29

Closed harpocrates closed 1 year ago

harpocrates commented 1 year ago

One of the invariants of Query.Or(lhs, rhs) is that the columns in lhs should match the columns in rhs (really they should be in the same order, but the runtime's columns are unordered, so that point is a little tenuous).

This invariant was violated in queries like the one added in tests. The crux is that the implied MATCH in the MERGE may bind additional variables that aren't needed or bound for the implied CREATE. This means that sometimes you end up with an Or(matchQuery, createQuery) where the matchQuery has extra columns not in the createQuery.

The fix is straightforward: since the variables bound in the CREATE are always a subset of those bound in the MATCH, we can adjust the MATCH side of the query to keep only the same variables coming out of the CREATE side.

emanb29 commented 1 year ago

Thank you!