How can you prevent this? Check your statements before you run them, best with EXPLAIN that parses them without execution. Use Integration Tests, e.g. with Docker/Testcontainers to check your cypher queries against your current database/dataset.
If you only have a uniqueness constraint, but not an existence constraint on your id
→
While you can CREATE
a node with a null id
(why would you),
you cannot use MERGE
on a null value for an id,
it will fail proactively and tell you what field was null.
MERGE (p:Person {id:null})
Error Message: Cannot merge node using null property value for id
Solution: You can filter out the null values in your source data, or in your statement before you reach the MERGE
,
e.g. with WITH * WHERE NOT row.id IS NULL
You misspelled or forgot to declare a variable and try to refer to it later. Or you had it declared in a previous statement which is now gone, they don’t carry over.
CREATE (p:Person {name:'David'});
RETURN p.name;
Error Message: Variable p
not defined
Solution: Make sure to
CREATE (:Product {title:"26" TV"})
Will fail because the string has a unescaped double quote
Error Message:
Invalid input 'T': expected whitespace, comment, '.', node labels, '[', "=~", IN, STARTS, ENDS, CONTAINS, IS, '^', '*', '/', '%', '+', '-', '=', '~', "<>", "!=", '<', '>', "<=", ">=", AND, XOR, OR, ',' or '}' (line 1, column 38 (offset: 37)) "CREATE (:Product {title:"26" TV"})" ^
Solution: Either fiddle around with backslash escapes \"
or just use parameters instead $title