refactor: remove useless de-indexation code in MemoryBackend

de-indexation was already achieved with the previous loop
This commit is contained in:
Éloi Rivard 2024-09-19 17:39:24 +02:00
parent b14cc2b5ad
commit 86623f6690
No known key found for this signature in database
GPG key ID: 7EDA204EA57DD184

View file

@ -197,7 +197,7 @@ class MemoryBackend(Backend):
old_state = self.index(instance.__class__)[instance.id]
# update the mirror attributes of the submodel instances
# update the index for each attribute
for attribute in instance.attributes:
attribute_values = listify(old_state.get(attribute, []))
for value in attribute_values:
@ -223,18 +223,5 @@ class MemoryBackend(Backend):
# remove the current object from the subinstance index
mirror_attribute_index.remove(subinstance_id)
# update the index for each attribute
for attribute in instance.attributes:
attribute_values = listify(old_state.get(attribute, []))
for value in attribute_values:
if (
value in self.attribute_index(instance.__class__, attribute)
and instance.id
in self.attribute_index(instance.__class__, attribute)[value]
):
self.attribute_index(instance.__class__, attribute)[value].remove(
instance.id
)
# update the id index
del self.index(instance.__class__)[instance.id]