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 Mar 27, 2024
1 parent c2c9398 commit 91fda50
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 @@ -260,6 +260,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 91fda50

Please sign in to comment.