neo4j-core icon indicating copy to clipboard operation
neo4j-core copied to clipboard

on_create_set() with set() generates invalid cypher

Open aekobear opened this issue 4 years ago • 1 comments

I'm trying to merge a node, set a property if a new node was created, and set another property regardless of create or match. The cypher for this works perfectly:

MERGE (t:Thing { name: 'something' })
ON CREATE SET t.created = 'yes'
SET t.foo = 'bar'

However, the neo4j-core Query:

q.merge(t: { Thing: { name: 'something' } })
  .on_create_set(t: { created: 'yes' })
  .set(t: { foo: 'bar' })

generates the cypher:

MERGE (t:Thing { name: 'something' })
SET t.foo = 'bar'
ON CREATE SET t.created = 'yes'

which is invalid because ON CREATE must immediately follow MERGE.

Runtime information:

Neo4j database version: 3.5.6 (Community) neo4j-core gem version: 9.0.0

aekobear avatar Sep 10 '19 15:09 aekobear

I will try to create a pull request for this one

aekobear avatar Sep 10 '19 15:09 aekobear