You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
isEdgeVariableReferenced has no CREATE/MERGE case: an edge read only inside a CREATE/MERGE inline property silently returns null #6573
Found during review of #6567/PR #6570. CypherVariableUsage.isEdgeVariableReferenced decides whether a MATCH-bound relationship variable keeps its real binding (vs. being anonymized for the CSR/GAV fast path) by walking every clause type in statement.getClausesInOrder(). The switch handles RETURN, WITH, UNWIND, SET, REMOVE, DELETE, FOREACH, SUBQUERY - but has no case CREATE / case MERGE, so it falls to default and the clause is never inspected.
Contrast with foreachReferencesVariable's own inner switch (same file), which explicitly treats a nested CREATE/MERGE conservatively:
caseCREATE:
caseMERGE:
// Inline property expressions inside CREATE/MERGE patterns may reference the variable.// Enumerating them cheaply is awkward, so stay conservative: keep the edge binding.returntrue;
The top-level switch never got the same treatment.
MATCH (a:Person)-[r:KNOWS]->(b:Person) CREATE (c:Note{since:r.since}) RETURNc.sinceASs
Expected: s = 2001. Actual: s = null - the relationship step binds r under an internal anonymous name (since nothing else in the query appears, to this check, to reference it), so the CREATE clause's r.since reads a missing binding and silently evaluates to null instead of the real value.
Suggested fix
Add a case CREATE: case MERGE: arm to the top-level switch in isEdgeVariableReferenced, mirroring foreachReferencesVariable's conservative return true (a false positive there only forgoes the CSR/GAV fast path; a false negative silently drops a still-referenced edge, which is the failure class this whole method exists to prevent - same reasoning that motivated #6567's fix). A regression test parallel to the existing CypherVariableUsageTest cases (setReadsItAsTargetAndAsValue, removeReadsIt, etc.) should cover both CREATE {prop: r.x} and MERGE (n {prop: r.x}).
Where
engine/src/main/java/com/arcadedb/query/opencypher/executor/CypherVariableUsage.java, the isEdgeVariableReferenced switch (around the RETURN/WITH/... cases).
Activity
fix(#6573): isEdgeVariableReferenced has no CREATE/MERGE case (#6689)