Reputation: 1160
I am running the following Cypher query:
WITH "CREATE (test:Test {id: 1})" AS cypher
CALL apoc.cypher.doIt(cypher, {}) YIELD value
CREATE (test2:Test2 {id: 2})
Afterwards, I run MATCH (a) RETURN a
and see that only one node, with Test
label is created. The second CREATE
statement doesn't seem to be run.
If I create Test2
before the CALL
, it does create the node as expected.
Can anyone explain why this is occurring, and how one might continue on with a query after this CALL
clause?
Thanks in advance!
Upvotes: 4
Views: 683
Reputation: 30407
The issue here is that since the cypher executed in apoc.cypher.doIt()
doesn't return any rows, YIELD yields nothing. You can confirm this by replacing your CREATE at the end with RETURN value
: No changes, no records.
There are no rows to operate on, and all operations are performed per-row, so CREATE never gets executed, there are no rows to run it on.
You'll need to return something in your executed cypher, return true
or something.
Always keep an eye out for how many rows your query is producing at various stages of your query, since your operations (match, create, etc) will be performed as many times as there are rows.
Upvotes: 5