Under the query => 3.16.5.3. Merge with unique constraints and partial matches
It is written in the doc that an error is thrown but in reality a new node is created with the properties specified
Ex - merge (p:Person {name : "Tanmay", age : "23"})
return p;
If a node without property age exists then the query above will create a new node with 2 properties name and age
I think you may have missed the Introduction section, which shows the graph that the queries in that section are executing upon. That graph includes a :Person node with the name 'Michael Douglas', but no role
property
Also, the examples in the section you cited use constraints from this section:
CREATE CONSTRAINT ON (n:Person) ASSERT n.name IS UNIQUE;
CREATE CONSTRAINT ON (n:Person) ASSERT n.role IS UNIQUE;
In the section you cited when we run the query:
MERGE (michael:Person { name: 'Michael Douglas', role: 'Gordon Gekko' })
RETURN michael
then an error should happen, because no such node exists, and in attempting to create a new node with both properties it would violate the uniqueness constraint since we already have a :Person node with the unique name property of "Michael Douglas"
Now that said, there IS a problem with the next example, in 3.16.5.4. We still get an error because it's basically the same uniqueness constraint being violated as in 3.16.5.3, but the reason in the description isn't accurate:
there is also another unique node with the role of 'Gordon Gekko' and MERGE
fails to match.
There is no such :Person node with role:'Gordon Gekko'
, so this part needs a bit of correcting. I've let the docs team know, as well as provided a suggestion to include the Cypher to create the sample graph that the examples are run against, that may make following the examples clearer.
thank you so much for clarification