diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2022-11-23 10:58:28 -0500 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2022-11-24 11:50:48 -0500 |
commit | df3bd8d29740e846d7faac842a6e2de16cf483f0 (patch) | |
tree | 32ebad081b7279839b2e26fde79a4e010ea2f2fc /lib/sqlalchemy/ext/mutable.py | |
parent | fbec926c4744aa97a48a011939354c8b8f8be566 (diff) | |
download | sqlalchemy-df3bd8d29740e846d7faac842a6e2de16cf483f0.tar.gz |
add "merge" to viewonly cascades; propagate NO_RAISE when merging
Fixed bug where :meth:`_orm.Session.merge` would fail to preserve the
current loaded contents of relationship attributes that were indicated with
the :paramref:`_orm.relationship.viewonly` parameter, thus defeating
strategies that use :meth:`_orm.Session.merge` to pull fully loaded objects
from caches and other similar techniques. In a related change, fixed issue
where an object that contains a loaded relationship that was nonetheless
configured as ``lazy='raise'`` on the mapping would fail when passed to
:meth:`_orm.Session.merge`; checks for "raise" are now suspended within
the merge process assuming the :paramref:`_orm.Session.merge.load`
parameter remains at its default of ``True``.
Overall, this is a behavioral adjustment to a change introduced in the 1.4
series as of :ticket:`4994`, which took "merge" out of the set of cascades
applied by default to "viewonly" relationships. As "viewonly" relationships
aren't persisted under any circumstances, allowing their contents to
transfer during "merge" does not impact the persistence behavior of the
target object. This allows :meth:`_orm.Session.merge` to correctly suit one
of its use cases, that of adding objects to a :class:`.Session` that were
loaded elsewhere, often for the purposes of restoring from a cache.
Fixes: #8862
Change-Id: I8731c7810460e6a71f8bf5e8ded59142b9b02956
Diffstat (limited to 'lib/sqlalchemy/ext/mutable.py')
0 files changed, 0 insertions, 0 deletions