Skip to content

Commit

Permalink
Fix return type of soft delete methods
Browse files Browse the repository at this point in the history
I don't know whether returning "nothing was deleted" is the best
option, but at least the returned value now has the correct type.

jazzband#541
  • Loading branch information
mthuurne committed Apr 10, 2024
1 parent c8fb79c commit 4cadfb6
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 0 deletions.
1 change: 1 addition & 0 deletions model_utils/managers.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,7 @@ def delete(self):
field to True)
"""
self.update(is_removed=True)
return (0, {}) # no objects were actually deleted


class SoftDeletableQuerySet(SoftDeletableQuerySetMixin, QuerySet):
Expand Down
1 change: 1 addition & 0 deletions model_utils/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ def delete(self, using=None, soft=True, *args, **kwargs):
if soft:
self.is_removed = True
self.save(using=using)
return (0, {}) # no objects were actually deleted
else:
return super().delete(using=using, *args, **kwargs)

Expand Down

0 comments on commit 4cadfb6

Please sign in to comment.