Skip to content

Commit

Permalink
Fix bug
Browse files Browse the repository at this point in the history
  • Loading branch information
loveleif committed Jan 13, 2025
1 parent 5e1991c commit 663aa45
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions core/src/main/java/apoc/refactor/GraphRefactoring.java
Original file line number Diff line number Diff line change
Expand Up @@ -916,19 +916,21 @@ private void copyRelationships(Node source, Node target, boolean delete, boolean
var startNode = rel.getStartNode();
var endNode = rel.getEndNode();

if (!createNewSelfRel && startNode.getElementId().equals(endNode.getElementId())) continue;

if (startNode.getElementId().equals(source.getElementId())) startNode = target;
if (endNode.getElementId().equals(source.getElementId())) endNode = target;
if (!createNewSelfRel && startNode.getElementId().equals(endNode.getElementId())) {
if (delete) rel.delete();
} else {
if (startNode.getElementId().equals(source.getElementId())) startNode = target;
if (endNode.getElementId().equals(source.getElementId())) endNode = target;

final var type = rel.getType();
final var properties = rel.getAllProperties();
final var type = rel.getType();
final var properties = rel.getAllProperties();

// Delete first to avoid breaking constraints.
if (delete) rel.delete();
// Delete first to avoid breaking constraints.
if (delete) rel.delete();

final var newRel = startNode.createRelationshipTo(endNode, type);
properties.forEach(newRel::setProperty);
final var newRel = startNode.createRelationshipTo(endNode, type);
properties.forEach(newRel::setProperty);
}
}
}
}

0 comments on commit 663aa45

Please sign in to comment.