Skip to content

Commit

Permalink
fix: return True upon successful delete operation
Browse files Browse the repository at this point in the history
- Ensure `delete` method returns True to confirm deletion.
- Added a test to verify deletion behavior and return value.

Generated-by: aiautocommit
  • Loading branch information
iloveitaly committed Jan 11, 2025
1 parent 8594dff commit 444a5f5
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
2 changes: 1 addition & 1 deletion activemodel/base_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ def delete(self):

session.delete(self)
session.commit()
session.refresh(self)
return True

def save(self):
with get_session() as session:
Expand Down
19 changes: 19 additions & 0 deletions test/delete_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
from activemodel import BaseModel
from activemodel.mixins import TypeIDMixin

TYPEID_PREFIX = "myid"


class ExampleWithId(BaseModel, TypeIDMixin(TYPEID_PREFIX), table=True):
pass


def test_delete(create_and_wipe_database):
example = ExampleWithId().save()

assert ExampleWithId.count() == 1

result = example.delete()

assert ExampleWithId.count() == 0
assert result is True

0 comments on commit 444a5f5

Please sign in to comment.