I am writing some integration tests with GraphUnit support and have noticed strange behavior when trying to update a child of a node to existing relationship points.
Given the existing relationship with the support schedule, which is as follows:
(A:ParentNode)-[:SOME_REL {id: 1}]->(B:ChildNode)
If I try to update it by writing code, for example:
ChildNode newChildNode = new ChildNode();
existingRelationship.setChild(newChild);
RelationshipRepository.save(existingRelationship);
The resulting graph is as follows:
(A:ParentNode)
(B:ChildNode)
(C:ChildNode)
But I expect it to look like this:
(A:ParentNode)-[:SOME_REL {id: 1}]->(C:ChildNode)
The raw log output that I see when executing GraphRepository save()includes a DELETE statement in a Cypher request that discards the relation:
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}]}
? SDN4 ? , ?