From f9c4b5ea7deca071d38e89cbd5643b98f78dd25f Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Mon, 26 Mar 2018 18:10:16 -0400 Subject: [PATCH] Link to the ExpireRelationshipOnFKChange recipe for deletes The recipe now supports interception of delete() and a corresponding update of related objects. Change-Id: I2aa3bfdd477ceccff6cfb3e66ed73311705010c7 --- doc/build/orm/session_basics.rst | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/doc/build/orm/session_basics.rst b/doc/build/orm/session_basics.rst index 010c210acd..6f3500abbb 100644 --- a/doc/build/orm/session_basics.rst +++ b/doc/build/orm/session_basics.rst @@ -618,11 +618,13 @@ desired state:: >>> address in user.addresses False -The usual practice of deleting items within collections is to forego the usage -of :meth:`~.Session.delete` directly, and instead use cascade behavior to -automatically invoke the deletion as a result of removing the object from -the parent collection. The ``delete-orphan`` cascade accomplishes this, -as illustrated in the example below:: +There is a recipe for intercepting :meth:`.Session.delete` and invoking this +expiration automatically; see `ExpireRelationshipOnFKChange `_ for this. However, the usual practice of +deleting items within collections is to forego the usage of +:meth:`~.Session.delete` directly, and instead use cascade behavior to +automatically invoke the deletion as a result of removing the object from the +parent collection. The ``delete-orphan`` cascade accomplishes this, as +illustrated in the example below:: class User(Base): __tablename__ = 'user' @@ -664,6 +666,7 @@ it will be deleted on flush:: See also :ref:`unitofwork_cascades` for detail on cascades. + Deleting based on Filter Criterion ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -- 2.47.2