Repository navigation
Description
Summary
MergeStep.applySetClause is a private second implementation of the SET clause, used for ON CREATE SET / ON MATCH SET. It handles only the variable.property shape, so the dynamic-key form and the expression-target forms - both of which the shared parser happily produces for a MERGE action - are silently dropped with no error.
Where (HEAD 9c9d024db)
engine/src/main/java/com/arcadedb/query/opencypher/executor/steps/MergeStep.java:1351-1360, the case PROPERTY: branch reads only two fields:
final Object obj = result.getProperty(variable); // :1352
...
final String property = item.getProperty(); // :1360It never looks at SetItem.getKeyExpression() or SetItem.getTargetExpression(), which SetStep does handle (SetStep.java:174 for the dynamic key, :227 for the expression target).
visitMergeClause builds the merge actions with the shared visitSetClause (CypherASTBuilder.java:812), so both shapes reach applySetClause:
- the dynamic-key form (
CypherASTBuilder.java:712) arrives withproperty == nulland the key inkeyExpression - the expression-target forms (
:696,:701,:715) arrive withvariable == null
Consequences:
variable == nullmakesresult.getProperty(null)return null (ResultInternal.java:149has no null-name case), so the switch hitscontinueat:1355and the SET item vanishes.- For the dynamic-key form
propertyis null, so the code callsdoc.has(null)/mutableDoc.set(null, coerced);MutableDocument.setdoesmap.put(name, ...)into aLinkedHashMap(MutableDocument.java:195), so the computed key is never used. - The branch also skips the
validatePropertyValue()guardSetStepapplies (SetStep.java:265), soON CREATE SET n.p = {a:1}stores a map as a property value where the identical plainSETraisesTypeError: InvalidPropertyType.
Repro
CREATE (:P {id:1});
MERGE (n:P {id:1}) ON MATCH SET n[$k] = 5 -- with $k = 'score'No score property is written and no error is raised. Likewise:
MERGE (n:P {id:1}) ON MATCH SET (CASE WHEN true THEN n END).x = 1is a silent no-op.
OpenCypherDynamicPropertyMutationIssue5141Test covers exactly these two forms for plain SET/REMOVE - that is what #5141 fixed - but contains no MERGE case, so the regression suite never reaches this copy of the logic.
Suggested fix
Make MergeStep.applySetClause delegate to the same code path as SetStep: extract SetStep's applyPropertySet/applyReplaceMap/applyMergeMap/applyLabels into a shared helper and call it from both, instead of maintaining a second switch that has to be kept in sync by hand. (See also the companion issue about SET n = <node>, which is the mirror-image divergence: there the MergeStep copy is the one that is right.)
Scope / confidence
High. Verified that the merge actions are not parsed by a restricted builder, that CypherSemanticValidator.validateSetClauseScope (:1099) only checks variable scope, and that ResultInternal.getProperty does not throw on a null name.
Activity
Merge pull request #6863 from ArcadeData/fix/6831-6832-cypher-set-uni…
fix(ArcadeData#6831,ArcadeData#6832): one implementation of the openC…