Skip to content
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

Fixes #303 - constraint issue (create before delete) with mergeNodes #389

Merged
merged 1 commit into from
Apr 19, 2017

Conversation

DanielBerton
Copy link

No description provided.

copyRelationships(source, copyProperties(source, copyLabels(source, target)), delete);
if (delete) source.delete();
Map<String, Object> propTemp = new HashMap<>();
List<String> keys = new ArrayList<>();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do we need keys?

@@ -299,16 +299,30 @@ public void categorize(
}

private Node mergeNodes(Node source, Node target, boolean delete) {
copyRelationships(source, copyProperties(source, copyLabels(source, target)), delete);
if (delete) source.delete();
Map<String, Object> propTemp = new HashMap<>();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we find a better name? why not just Map<String, Object> properties = source.getAllProperties()

Didn't we say that we just store/keep the existing properties and then set the new ones after deletion of the source node? Not sure why we have to remove the properties individually?

return target;
}

private void setProperty(Map<String, Object> propTemp, List<String> keys, Node target) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isn't that the same as copy properties? only from a map source? Best name it the same and have it return the target node too.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jexp so we remane it copyProperties with this signature private Node copyProperties(Map<String, Object> properties, Node target) right?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes

private Node copyRelationships(Node source, Node target, boolean delete) {
for (Relationship rel : source.getRelationships()) {
copyRelationship(rel, source, target);
if (delete) rel.delete();
}
if (delete) source.delete();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will this break any other code that uses this? I think the original contract for this method was that rels are deleted but the nodes are left alone.
so I'd rather move this out of the method back into mergeNodes where it originally was.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jexp ok so we move back the delete into mergeNodes before the call of copyProperties method

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes

@DanielBerton
Copy link
Author

@jexp change requests fixed

@jexp
Copy link
Member

jexp commented Apr 19, 2017

Looks great, thanks a lot.

@jexp jexp merged commit 16ea4a1 into neo4j-contrib:3.1 Apr 19, 2017
albertodelazzari pushed a commit to albertodelazzari/neo4j-apoc-procedures that referenced this pull request Jun 28, 2017
ncordon added a commit to ncordon/neo4j-apoc-procedures that referenced this pull request Nov 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants