Skip to content

Give unique element ids for virtual nodes as well #745

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: dev
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions common/src/main/java/apoc/result/VirtualNode.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public VirtualNode(Label[] labels, Map<String, Object> props) {
this.id = MIN_ID.decrementAndGet();
addLabels(asList(labels));
this.props.putAll(props);
this.elementId = null;
this.elementId = UUID.randomUUID().toString();
}

@SuppressWarnings("unused") // used from extended
Expand All @@ -68,11 +68,13 @@ public VirtualNode(Node node, List<String> propertyNames, boolean wrapNodeIDs) {
final long id = node.getId();
// if node is already virtual, we return the same id
this.id = id < 0 || wrapNodeIDs ? id : MIN_ID.decrementAndGet();
this.elementId = id < 0 || wrapNodeIDs
? node.getElementId()
: UUID.randomUUID().toString();
// to not overlap this nodes ids with ids from VirtualNode(Label[] labels, Map<String, Object> props)
this.labels.addAll(Util.labelStrings(node));
String[] keys = propertyNames.toArray(new String[propertyNames.size()]);
this.props.putAll(node.getProperties(keys));
this.elementId = node.getElementId();
}

public VirtualNode(Node node, List<String> propertyNames) {
Expand Down
Loading