MCPcopy Create free account
hub / github.com/tortoise/tortoise-orm / DeleteQuery

Class DeleteQuery

tortoise/queryset.py:1357–1403  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1355
1356
1357class DeleteQuery(AwaitableQuery):
1358 __slots__ = (
1359 "_annotations",
1360 "_custom_filters",
1361 "_orderings",
1362 "_limit",
1363 )
1364
1365 def __init__(
1366 self,
1367 model: type[MODEL],
1368 db: BaseDBAsyncClient,
1369 q_objects: list[Q],
1370 annotations: dict[str, Any],
1371 custom_filters: dict[str, FilterInfoDict],
1372 limit: int | None,
1373 orderings: list[tuple[str, str]],
1374 ) -> None:
1375 super().__init__(model)
1376 self._q_objects = q_objects
1377 self._annotations = annotations
1378 self._custom_filters = custom_filters
1379 self._db = db
1380 self._limit = limit
1381 self._orderings = orderings
1382
1383 def _make_query(self) -> None:
1384 self.query = copy(self.model._meta.basequery)
1385 if self.capabilities.support_update_limit_order_by and self._limit:
1386 self.query._limit = self.query._wrapper_cls(self._limit)
1387 self.resolve_ordering(
1388 model=self.model,
1389 table=self.model._meta.basetable,
1390 orderings=self._orderings,
1391 annotations=self._annotations,
1392 )
1393 self.resolve_filters()
1394 self.query._delete_from = True
1395 return
1396
1397 def __await__(self) -> Generator[Any, None, int]:
1398 self._choose_db_if_not_chosen(True)
1399 self._make_query()
1400 return self._execute().__await__()
1401
1402 async def _execute(self) -> int:
1403 return (await self._db.execute_query(*self.query.get_parameterized_sql()))[0]
1404
1405
1406class ExistsQuery(AwaitableQuery):

Callers 1

deleteMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…