Skip to content

Commit

Permalink
adding check for nullity in queryset delete
Browse files Browse the repository at this point in the history
  • Loading branch information
AllenWang314 committed Oct 4, 2024
1 parent 711d7fb commit 0268e0b
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions safedelete/queryset.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,10 @@ def delete(self, force_policy: Optional[int] = None) -> Tuple[int, Dict[str, int
deleted_counter: Counter = Counter()
# TODO: Replace this by bulk update if we can
for obj in self.all():
_, delete_response = obj.delete(force_policy=force_policy)
deleted_counter.update(delete_response)
res = obj.delete(force_policy=force_policy)
if res is not None:
_, delete_response = res
deleted_counter.update(delete_response)
self._result_cache = None
return sum(deleted_counter.values()), dict(deleted_counter)
delete.alters_data = True # type: ignore
Expand Down

0 comments on commit 0268e0b

Please sign in to comment.