I am writing some GraphUnit supported integration tests and have noticed odd behavior when I attempt to update the child node an existing relationship points to.
Given an existing relationship with a backing graph that looks like:
(A:ParentNode)-[:SOME_REL {id: 1}]->(B:ChildNode)
If I try to update it by writing code like:
ChildNode newChildNode = new ChildNode();
existingRelationship.setChild(newChild);
RelationshipRepository.save(existingRelationship);
The resulting graph looks like:
(A:ParentNode)
(B:ChildNode)
(C:ChildNode)
But I expect it to look like:
(A:ParentNode)-[:SOME_REL {id: 1}]->(C:ChildNode)
The raw log output I see when I execute the GraphRepository save()
includes a DELETE statement in the Cypher query that drops the relationship:
10:32:32.218 [main] DEBUG o.n.o.s.r.SessionRequestHandler - {"statements":[{"statement":"MATCH ()-[_0]->() WHERE id(_0)=0 SET _0+={_0_props} WITH _0 MATCH ($0)-[_1:`SOME_REL`]->($1) WHERE id($0)=0 AND id($1)=1 AND id(_1)=0 DELETE _1","parameters":{"_0_props":{"doubleProp":1.0}},"resultDataContents":["row"],"includeStats":false}]}
10:32:32.219 [main] INFO o.n.o.session.request.DefaultRequest - POST http://localhost:7475/db/data/transaction/commit, request: {"statements":[{"statement":"MATCH ()-[_0]->() WHERE id(_0)=0 SET _0+={_0_props} WITH _0 MATCH ($0)-[_1:`SOME_REL`]->($1) WHERE id($0)=0 AND id($1)=1 AND id(_1)=0 DELETE _1","parameters":{"_0_props":{"doubleProp":1.0}},"resultDataContents":["row"],"includeStats":false}]}
Is this a bug? Or am I not updating an SDN4 relationship entity properly? Do we have to delete relationships and create them from scratch each time we effectively want to do an update?