I am trying to create a node with a label that starts with a numeric character. I was following the documentation and other stack overflow answers, but I was never able to get this to work.
https://neo4j.com/docs/cypher-manual/current/syntax/naming/#symbolic-names-escaping-rules
I have tried multiple different solution from inlining backticks with ` and wrapping different parts of the query with backticks.
const escapedName = escapeLabel(uniqueIdentifier);
const queryInsert = `
MERGE (w:example::${escapedName})
RETURN w
`;
function escapeLabel(label: string): string {
if (/^[0-9]/.test(label)) {
return "`" + label + "`";
}
return label;
}
When I console log the query insert I see the backticks
{
queryInsert: "n MERGE (w:example::`9tV3G7nWMnduftSTQtzB4xpHK4iz1`) n RETURN wn ",
}
But the error message says
Neo4jError: Invalid input '::': expected ")", "WHERE", "{" or a parameter (line 2, column 17 (offset: 19))
" MERGE (w:example::`9tV3G7nWMnduftSTQtzB4xpHK4iz1`)"
If I changed the input to a label that doesn’t start with a numeric character, it all works fine.
^
mediocoreengineer is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.