Skip to content

Refactor::MergeNodes handle relationship properties #702

@damianbenente

Description

@damianbenente

Currently the void Refactor::MergeNodes( work grate for the nodes but for the relationships it only recreate in a new one pointing to the merged node but the new one is empty discarding all the properties as the graph.CreateRelationship doesn't handle properties

...

// Handle relationships
      // Copy all relationships from source to target
      if (mergeRels) {
        auto in_rels = source_node.InRelationships();
        for (const auto &rel : in_rels) {
          graph.CreateRelationship(rel.From(), target_node, rel.Type());
        }

        auto out_rels = source_node.OutRelationships();
        for (const auto &rel : out_rels) {
          graph.CreateRelationship(target_node, rel.To(), rel.Type());
        }
      }

      // Delete the source node
      graph.DetachDeleteNode(source_node);
    }

it would be nice if it can handle to recreate the properties to maybe something like

if (mergeRels) 
        auto in_rels = source_node.InRelationships();
        for (const auto &rel : in_rels) {
          auto new_rel = graph.CreateRelationship(rel.From(), target_node, rel.Type());
          new_rel.SetProperties(rel.Properties);
        }


        auto out_rels = source_node.OutRelationships();
        for (const auto &rel : out_rels) {
          auto new_rel = graph.CreateRelationship(target_node, rel.To(), rel.Type());
          new_rel.SetProperties(rel.Properties());
        }
      }
  • I don't have any experience with the c++ api so maybe the code is not wright or need modifications, if its there a easy way to make a dev environment to compile and test it I can do it, have experience with c++ but for embedded microcontrollers that the dev part are simpler. otherwise it looks like a simple change with will improve a lot the refactor module.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions