]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commit
disable raise sql for the delete cascade
authorMike Bayer <mike_mp@zzzcomputing.com>
Sun, 26 Mar 2023 16:30:35 +0000 (12:30 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Tue, 28 Mar 2023 13:59:51 +0000 (09:59 -0400)
commit9e85abb221af13057621ea066af4e15b2f1dfb03
treefdf0ca34554fbd87f9a5538cd28ab877434530cc
parentce4e1770f01a6c19d3a55621529e3f98607d7824
disable raise sql for the delete cascade

Towards maintaining consistency with unit-of-work changes made for
:ticket:`5984` and :ticket:`8862`, both of which disable "lazy='raise'"
handling within :class:`_orm.Session` processes that aren't triggered by
attribute access, the :meth:`_orm.Session.delete` method will now also
disable "lazy='raise'" handling when it traverses relationship paths in
order to process the "delete" and "delete-orphan" cascade rules.
Previously, there was no easy way to generically call
:meth:`_orm.Session.delete` on an object that had "lazy='raise'" set up
such that only the necessary relationships would be loaded. As
"lazy='raise'" is primarily intended to catch SQL loading that emits on
attribute access, :meth:`_orm.Session.delete` is now made to behave like
other :class:`_orm.Session` methods including :meth:`_orm.Session.merge` as
well as :meth:`_orm.Session.flush` along with autoflush.

Fixes: #9549
Change-Id: Ie049e66ce2bd35900eae4af0e9b795633303ca63
doc/build/changelog/unreleased_20/9549.rst [new file with mode: 0644]
lib/sqlalchemy/orm/relationships.py
test/orm/test_cascade.py