Cypher: delete -> match -> count will count wrong on the first try #466

Closed
flipside opened this Issue Jan 29, 2013 · 2 comments

Comments

Projects
None yet
2 participants

I found this bug while trying to update a counter for the number of relationships on a node after deleting 1 or more relationships. The workaround is to count a second time.

Example 1: http://console.neo4j.org/r/3jzrwy

start n=node(0)
match n-[r?:TEST]->()
with n, COUNT(r) as c0 foreach(i in [1,2,3,4,5] :
create unique n-[:TEST]->(m {id: i}))
match n-[r?:TEST]-m
delete r, m
with n, c0
match n-[r?:TEST]->()
with n, c0, COUNT(r) as c1
match n-[r?:TEST]->()
return n, c0, c1, COUNT(r) as c2

Example 2: http://console.neo4j.org/r/6t8v0p

start n=node(0)
match n-[r?:TEST]->()
with n, COUNT(r) as c0 foreach(i in [1,2,3,4,5] :
create unique n-[:TEST]->(m {id: i}))
match n-[r?:TEST]->()
with n, c0, COUNT(r) as c1
match n-[r?:TEST]->m
delete r, m
with n, c0, c1, COUNT(r) as c2
match n-[r?:TEST]->()
return n, c0, c1, c2, COUNT(r) as c3

flipside commented Feb 2, 2013

So it's pretty clear to me now that a delete command takes a few ms to register before it won't be counted or matched. A work around is to give the system "busy work" until the delete goes through such as a match or count.

This is the same delete error I describe in #393.

Contributor

jakewins commented Oct 23, 2013

Closing as duplicate of #393

@jakewins jakewins closed this Oct 23, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment