neo4jrb / neo4j-core

A simple unified API that can access both the server and embedded Neo4j database. Used by the neo4j gem
MIT License
99 stars 80 forks source link

on_create_set() with set() generates invalid cypher #332

Open aekobear opened 5 years ago

aekobear commented 5 years ago

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 commented 5 years ago

I will try to create a pull request for this one