From: Mike Bayer Date: Mon, 26 Mar 2018 22:10:16 +0000 (-0400) Subject: Link to the ExpireRelationshipOnFKChange recipe for deletes X-Git-Tag: rel_1_3_0b1~222 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f9c4b5ea7deca071d38e89cbd5643b98f78dd25f;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git Link to the ExpireRelationshipOnFKChange recipe for deletes The recipe now supports interception of delete() and a corresponding update of related objects. Change-Id: I2aa3bfdd477ceccff6cfb3e66ed73311705010c7 --- 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 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~