Mark an instance as deleted. The object is assumed to be either :term:`persistent` or :term:`detached` when passed; after the method is called, the object will remain in the :term:`persistent` state until the next flush proceeds. During this time, the object will al
(self, instance: object)
| 3621 | self._save_or_update_impl(st_) |
| 3622 | |
| 3623 | def delete(self, instance: object) -> None: |
| 3624 | """Mark an instance as deleted. |
| 3625 | |
| 3626 | The object is assumed to be either :term:`persistent` or |
| 3627 | :term:`detached` when passed; after the method is called, the |
| 3628 | object will remain in the :term:`persistent` state until the next |
| 3629 | flush proceeds. During this time, the object will also be a member |
| 3630 | of the :attr:`_orm.Session.deleted` collection. |
| 3631 | |
| 3632 | When the next flush proceeds, the object will move to the |
| 3633 | :term:`deleted` state, indicating a ``DELETE`` statement was emitted |
| 3634 | for its row within the current transaction. When the transaction |
| 3635 | is successfully committed, |
| 3636 | the deleted object is moved to the :term:`detached` state and is |
| 3637 | no longer present within this :class:`_orm.Session`. |
| 3638 | |
| 3639 | .. seealso:: |
| 3640 | |
| 3641 | :ref:`session_deleting` - at :ref:`session_basics` |
| 3642 | |
| 3643 | :meth:`.Session.delete_all` - multiple instance version |
| 3644 | |
| 3645 | """ |
| 3646 | if self._warn_on_events: |
| 3647 | self._flush_warning("Session.delete()") |
| 3648 | |
| 3649 | self._delete_impl(object_state(instance), instance, head=True) |
| 3650 | |
| 3651 | def delete_all(self, instances: Iterable[object]) -> None: |
| 3652 | """Calls :meth:`.Session.delete` on multiple instances. |