Skip to content

Commit

Permalink
refactor: remove useless de-indexation code in MemoryBackend
Browse files Browse the repository at this point in the history
de-indexation was already achieved with the previous loop
  • Loading branch information
azmeuk committed Sep 19, 2024
1 parent b14cc2b commit 86623f6
Showing 1 changed file with 1 addition and 14 deletions.
15 changes: 1 addition & 14 deletions canaille/backends/memory/backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ def index_delete(self, instance):

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:
Expand All @@ -223,18 +223,5 @@ def index_delete(self, instance):
# 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]

0 comments on commit 86623f6

Please sign in to comment.