fix(relationship 2.0): handle the case where aspects can have multiple fields with the same relationship type #476
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Currently, these is a "bug" where aspects that have multiple relationship fields of the same relationship type will not have all of them persisted properly in the DB. This is because the current logic for extracting relationships from aspect fields keeps all the extracted relationships separate by the field it was derived from. Then, the relationships are ingested sequentially by each field name group. Relationships in 2.0 are ingested using REMOVE_ALL_EDGES_FROM_SOURCE so any earlier relationships will get overwritten by later relationships if the later ones are of the same type as the earlier ones.
The new logic will group them by relationship class. Each relationship class will be processed sequentially. This way, there is never any overlap of types between different relationship groups. So any deletions will only occur on previously existing relationships, not relationships added earlier in the current ingestion.
Testing Done
Updated unit tests
Checklist