]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commit
disallow adding to identity map that's been discarded
authorMike Bayer <mike_mp@zzzcomputing.com>
Fri, 1 Oct 2021 22:04:46 +0000 (18:04 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Mon, 4 Oct 2021 18:38:21 +0000 (14:38 -0400)
commite7e0757efe042b8343ef44d4f61a33cdbc072ff3
treede1ec0739f872c80d1cb3c617b28c46e17471b71
parent71e463506217e3acc379a3f459e68a81792a0aac
disallow adding to identity map that's been discarded

Fixed bug where iterating a :class:`.Result` from a :class:`_orm.Session`
after that :class:`_orm.Session` were closed would partially attach objects
to that session in an essentially invalid state.   It now raises an exception
with a link to new documentation if an **un-buffered** result is iterated
from a :class:`_orm.Session` that was closed or otherwise had the
:meth:`_orm.Session.expunge_all` method called after that :class:`.Result`
was generated.  The "prebuffer_rows" execution option, as is used by the
asyncio extension, may be used to produce a :class:`.Result` where the ORM
objects are prebuffered, and in this case iterating the result will produce
a series of detached objects.

Fixes: #7128
Change-Id: I59f0ae32a83a64587937741b80f31ff825bbb574
doc/build/changelog/unreleased_14/7128.rst [new file with mode: 0644]
doc/build/errors.rst
lib/sqlalchemy/orm/identity.py
lib/sqlalchemy/orm/session.py
test/orm/test_session.py