]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commit
cascade fixes revealed by the removal of cascade_backrefs
authorMike Bayer <mike_mp@zzzcomputing.com>
Tue, 11 Jul 2023 13:58:22 +0000 (09:58 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Tue, 11 Jul 2023 15:34:04 +0000 (11:34 -0400)
commitd60bb4b4a8006f88fd24a4efe1b865f58ac07ed1
tree7ef1c74bfa9f6b5fc24c284ff8e42e4891f79a2a
parent03f168cf19bd037905b1c8dc282235a064b368bd
cascade fixes revealed by the removal of cascade_backrefs

Fixed issue where setting a relationship collection directly, where an
object in the new collection were already present, would not trigger a
cascade event for that object, leading to it not being added to the
:class:`_orm.Session` if it were not already present.  This is similar in
nature to :ticket:`6471` and is a more apparent issue due to the removal of
``cascade_backrefs`` in the 2.0 series.  The
:meth:`_orm.AttributeEvents.append_wo_mutation` event added as part of
:ticket:`6471` is now also emitted for existing members of a collection
that are present in a bulk set of that same collection.

Fixed issue where objects that were associated with an unloaded collection
via backref, but were not merged into the :class:`_orm.Session` due to the
removal of ``cascade_backrefs`` in the 2.0 series, would not emit a warning
that these objects were not being included in a flush, even though they
were pending members of the collection; in other such cases, a warning is
emitted when a collection being flushed contains non-attached objects which
will be essentially discarded.  The addition of the warning for
backref-pending collection members establishes greater consistency with
collections that may be present or non-present and possibly flushed or not
flushed at different times based on different relationship loading
strategies.

Fixes: #10089
Fixes: #10090
Change-Id: I95610c17745f32141475cc6b4a4a5c6fc678fd05
doc/build/changelog/unreleased_20/10089.rst [new file with mode: 0644]
doc/build/changelog/unreleased_20/10090.rst [new file with mode: 0644]
lib/sqlalchemy/orm/attributes.py
lib/sqlalchemy/orm/base.py
lib/sqlalchemy/orm/collections.py
lib/sqlalchemy/orm/dependency.py
lib/sqlalchemy/orm/state.py
test/orm/test_cascade.py
test/orm/test_load_on_fks.py
test/orm/test_mapper.py