Skip to content

Support for multiple relations on the same entity #21

@wtfuii

Description

@wtfuii

This could be either classified as a bug or a missing feature:

Given the following Relationships:

One "Person" has Many "Friends".
One "Person" has Many "Kids".
One "Kid" has one "Godparent" - "Godparent" being a foreign key relationship to a row in the "Friends" table.

If a "Person" is getting cloned including its relationships, the "Friends" who are also "Godparents" in of a "Kid" will be duplicated in the "Friends" table.

Solution:

  1. Save every copied entity in a dictionary, having the original ID and type as key.
  2. Whenever a related entity is being set in the graph, check if the dictionary contains an instance with the original key.
  3. If it does not, reset the instance and add it to the dictionary.
  4. Set the relationship using the instance from the dictionary.

Those steps make sure, that all relationships are using the same instance of entities with a specific key.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions