Update ListAttributes
identically when removing edges or nodes
#2280
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.
Description
The behaviour regarding
ListAttributes
was different depending on whether an edge or a node was removed:ListAttribute
that was the destination of that edge had its corresponding element completely removed;ListAttribute
that was the destination of one of the node's edges had its corresponding element reset, but not removed.With this behaviour, a user had different UIDs depending on whether a single edge or the whole node had been removed where the UID should always be identical.
This PR ensures that removing a node has the same effect on a connected node as removing an edge: it thus removes completely an element connected to a
ListAttribute
when the node is removed.Implementation remarks
When collecting the outgoing edges, we now check whether the edge is connected to a
ListAttribute
. If it is, we associate the attribute of the outgoing edge to a tuple containing theListAttribute
it is connected to and its value (if it has any). We then remove the corresponding element in theListAttribute
the edge is connected to.When recreating a node that has been removed (either by performing an "Undo" action or by upgrading a node), this map is used to check whether the edge that will be re-added is to be connected to a
ListAttribute
. If it is, a new element is added to theListAttribute
with the value stored in the map. Re-creating the entry in the list is necessary: if it does not exist, the edge will not have any destination attribute to connect to.