Ross G
Ross G

Reputation: 51

Neo4j/Cypher Delete with Where "Unknown identifier"

I've made the mistake of being inconsistent with attribute types. For nodes of type "person", some have a string for the "external_id" property, and some have an int. I'd like to delete all nodes where the property is a string. The following query runs and seems to give a correct answer.

MATCH (n:person)
WHERE TOSTRING(n.external_id) = n.external_id
RETURN count(n)

However, when I try to delete those nodes using the following query, I get "Unknown identifier `n`.":

MATCH (n:person)
WHERE TOSTRING(n.external_id) = n.external_id
DELETE n

I'm new to Neo4j and Cypher, but this seems like it should be pretty straightforward. I've already deleted all of the relationships for these nodes. What am I missing here?

Upvotes: 5

Views: 127

Answers (2)

Olivia Ytterbrink
Olivia Ytterbrink

Reputation: 11

This is a duplicate of https://github.com/neo4j/neo4j/issues/5768 which was fixed by https://github.com/neo4j/neo4j/pull/5807

Upvotes: 1

Ross G
Ross G

Reputation: 51

It turns out this is a bug as @JeremyKendall suggested. It only came up because I have a uniqueness constraint on person.external_id. I found a simple workaround by copying the value of the external_id property into a temporary property on each person node (without a uniqueness constraint), and then deleting all nodes where that temporary property was a string.

Upvotes: 0

Related Questions