Skip to content
This repository

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

Closed
flipside opened this Issue January 28, 2013 · 2 comments

2 participants

Mat Tyndall Jacob Hansson
Mat Tyndall

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

Mat Tyndall

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.

Jacob Hansson
Collaborator

Closing as duplicate of #393

Jacob Hansson jakewins closed this October 23, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.