MCPcopy Create free account
hub / github.com/sqlalchemy/sqlalchemy / after_delete

Method after_delete

lib/sqlalchemy/orm/events.py:1472–1518  ·  view source on GitHub ↗

Receive an object instance after a DELETE statement has been emitted corresponding to that instance. .. note:: this event **only** applies to the :ref:`session flush operation ` and does **not** apply to the ORM DML operations described at

(
        self, mapper: Mapper[_O], connection: Connection, target: _O
    )

Source from the content-addressed store, hash-verified

1470 """
1471
1472 def after_delete(
1473 self, mapper: Mapper[_O], connection: Connection, target: _O
1474 ) -> None:
1475 """Receive an object instance after a DELETE statement
1476 has been emitted corresponding to that instance.
1477
1478 .. note:: this event **only** applies to the
1479 :ref:`session flush operation <session_flushing>`
1480 and does **not** apply to the ORM DML operations described at
1481 :ref:`orm_expression_update_delete`. To intercept ORM
1482 DML events, use :meth:`_orm.SessionEvents.do_orm_execute`.
1483
1484 This event is used to emit additional SQL statements on
1485 the given connection as well as to perform application
1486 specific bookkeeping related to a deletion event.
1487
1488 The event is often called for a batch of objects of the
1489 same class after their DELETE statements have been emitted at
1490 once in a previous step.
1491
1492 .. warning::
1493
1494 Mapper-level flush events only allow **very limited operations**,
1495 on attributes local to the row being operated upon only,
1496 as well as allowing any SQL to be emitted on the given
1497 :class:`_engine.Connection`. **Please read fully** the notes
1498 at :ref:`session_persistence_mapper` for guidelines on using
1499 these methods; generally, the :meth:`.SessionEvents.before_flush`
1500 method should be preferred for general on-flush changes.
1501
1502 :param mapper: the :class:`_orm.Mapper` which is the target
1503 of this event.
1504 :param connection: the :class:`_engine.Connection` being used to
1505 emit DELETE statements for this instance. This
1506 provides a handle into the current transaction on the
1507 target database specific to this instance.
1508 :param target: the mapped instance being deleted. If
1509 the event is configured with ``raw=True``, this will
1510 instead be the :class:`.InstanceState` state-management
1511 object associated with the instance.
1512 :return: No return value is supported by this event.
1513
1514 .. seealso::
1515
1516 :ref:`session_persistence_events`
1517
1518 """
1519
1520
1521class _MapperEventsHold(_EventsHold[_ET]):

Callers 1

delete_objFunction · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected