Skip to content

fix: Preserve relationship properties upon refactor.merge_nodes#3948

Merged
mattkjames7 merged 7 commits intomemgraph:masterfrom
ranok:merge_nodes_fix
Mar 30, 2026
Merged

fix: Preserve relationship properties upon refactor.merge_nodes#3948
mattkjames7 merged 7 commits intomemgraph:masterfrom
ranok:merge_nodes_fix

Conversation

@ranok
Copy link
Copy Markdown
Contributor

@ranok ranok commented Mar 23, 2026

This diff addresses #3921 by iterating through all the of properties on the relationships that will be deleted and setting them on the newly-added relationships.

Tested on amd64 build of master memgraph and MAGE.

memgraph> CREATE (:PERSON {NAME: "John Doe"})-[:FRIENDS_WITH {LEVEL: "besties"}]->(:PERSON {NAME: "Bob Smith"});
Empty set (round trip in 0.000 sec)
2 labels have been created.
2 nodes have been created.
1 relationships have been created.
memgraph> CREATE (:PERSON {EMAIL: "John@Doe.com"});
Empty set (round trip in 0.000 sec)
1 labels have been created.
1 nodes have been created.
memgraph> MATCH p = ()-[rel]-() RETURN properties(rel);
+--------------------+
| properties(rel)    |
+--------------------+
| {LEVEL: "besties"} |
| {LEVEL: "besties"} |
+--------------------+
2 rows in set (round trip in 0.000 sec)
memgraph> MATCH (p1:PERSON {NAME: "John Doe"}), (p2:PERSON {EMAIL: "John@Doe.com"}) CALL refactor.merge_nodes([p2, p1], {properties: "override", mergeRels: true}) YIELD node RETURN node;
+-----------------------------------------------------+
| node                                                |
+-----------------------------------------------------+
| (:PERSON {EMAIL: "John@Doe.com", NAME: "John Doe"}) |
+-----------------------------------------------------+
1 row in set (round trip in 0.000 sec)
INFO: Sequential scan will be used on symbol `p1` although there is a filter on labels :PERSON and properties NAME. Consider creating a label-property index.
1 labels have been created.
1 nodes have been deleted.
2 properties have been updated.
1 relationships have been created.
1 relationships have been deleted.
memgraph> MATCH p = ()-[rel]-() RETURN properties(rel);
+--------------------+
| properties(rel)    |
+--------------------+
| {LEVEL: "besties"} |
| {LEVEL: "besties"} |
+--------------------+

Leave above in PR description, copy the below into a comment


Tracking

  • [Link to Epic/Issue]

Standard development

CI Testing Labels

  • Select the appropriate CI test labels (CI -build=build-name -test=test-suite)

Documentation checklist

  • Add the documentation label
  • Add the bug / feature label
  • Add the milestone for which this feature is intended
    • If not known, set for a later milestone
  • Write a release note, including added/changed clauses
    • Fixed propertied on relationships being deleted when running refactor.merge_nodes() - now properties on relationships are preserved. #3948
  • [ Documentation PR link memgraph/documentation#XXXX ]
    • Is back linked to this development PR

@ranok ranok force-pushed the merge_nodes_fix branch from 5d0f12e to eb342cc Compare March 23, 2026 21:50
@ranok ranok changed the title Preserve relationship properties upon refactor.merge_nodes fix: Preserve relationship properties upon refactor.merge_nodes Mar 23, 2026
@antejavor antejavor self-assigned this Mar 27, 2026
@ranok
Copy link
Copy Markdown
Contributor Author

ranok commented Mar 29, 2026

Added an e2e test for the property preservation to prevent regressions and also rang clang-format on the changed CPP file.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 30, 2026

Staging branch created: staging/8425e9a-master ✔️

CI Diff (External) run here

@mattkjames7 mattkjames7 linked an issue Mar 30, 2026 that may be closed by this pull request
@mattkjames7 mattkjames7 added this to the mg-v3.10.0 milestone Mar 30, 2026
@mattkjames7 mattkjames7 self-requested a review March 30, 2026 08:44
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 30, 2026

Staging branch created: staging/8425e9a ✔️

CI Package mage (External) run here

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 30, 2026

Staging branch created: staging/d112841 ✔️

CI Diff (External) run here

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 30, 2026

Staging branch created: staging/ccad71a ✔️

CI Diff (External) run here

@sonarqubecloud
Copy link
Copy Markdown

Copy link
Copy Markdown
Contributor

@mattkjames7 mattkjames7 left a comment

Choose a reason for hiding this comment

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

Looks good to me.

I made some changes to pass the clang-tidy checks. I have also built the image locally to test it, and it works as expected.

I'll place it into the merge queue, should be merged within about an hour.

Nice work! 💪

@mattkjames7 mattkjames7 enabled auto-merge March 30, 2026 13:23
@mattkjames7 mattkjames7 added bug bug Docs - changelog only Docs - changelog only labels Mar 30, 2026
@mattkjames7 mattkjames7 added this pull request to the merge queue Mar 30, 2026
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Mar 30, 2026
@mattkjames7 mattkjames7 added this pull request to the merge queue Mar 30, 2026
Merged via the queue into memgraph:master with commit 48ec054 Mar 30, 2026
41 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug bug Docs - changelog only Docs - changelog only

Projects

None yet

Development

Successfully merging this pull request may close these issues.

merge_nodes deletes relationship/edge properties from merged nodes

3 participants