MCPcopy
hub / github.com/tortoise/tortoise-orm / delete

Method delete

tortoise/models.py:1196–1209  ·  view source on GitHub ↗

Deletes the current model object. :param using_db: Specific DB connection to use instead of default bound :raises OperationalError: If object has never been persisted.

(self, using_db: BaseDBAsyncClient | None = None)

Source from the content-addressed store, hash-verified

1194 await self._post_save(db, created, update_fields)
1195
1196 async def delete(self, using_db: BaseDBAsyncClient | None = None) -> None:
1197 """
1198 Deletes the current model object.
1199
1200 :param using_db: Specific DB connection to use instead of default bound
1201
1202 :raises OperationalError: If object has never been persisted.
1203 """
1204 db = using_db or self._choose_db(True)
1205 if not self._saved_in_db:
1206 raise OperationalError("Can't delete unpersisted record")
1207 await self._pre_delete(db)
1208 await db.executor_class(model=self.__class__, db=db).execute_delete(self)
1209 await self._post_delete(db)
1210
1211 async def fetch_related(self, *args: Any, using_db: BaseDBAsyncClient | None = None) -> None:
1212 """

Callers 15

__init__Method · 0.45
_remove_or_clearMethod · 0.45
test_deleteFunction · 0.45
test_deleteFunction · 0.45
test_deleteFunction · 0.45
test_delete_limitFunction · 0.45
test_deleteFunction · 0.45

Calls 5

_choose_dbMethod · 0.95
_pre_deleteMethod · 0.95
_post_deleteMethod · 0.95
OperationalErrorClass · 0.90
execute_deleteMethod · 0.80

Tested by 15

test_deleteFunction · 0.36
test_deleteFunction · 0.36
test_deleteFunction · 0.36
test_delete_limitFunction · 0.36
test_deleteFunction · 0.36
test_noid_deleteFunction · 0.36
test_createFunction · 0.36