]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commit
immediateload lazy relationships named in refresh.attribute_names
authorMike Bayer <mike_mp@zzzcomputing.com>
Mon, 13 Feb 2023 16:17:09 +0000 (11:17 -0500)
committermike bayer <mike_mp@zzzcomputing.com>
Thu, 16 Feb 2023 00:09:18 +0000 (00:09 +0000)
commit3fd081d070716fd5fc578555f945d503f9a91f91
tree9becb3d07de9e69cc1681f19e7f11ab71268e506
parent8855656626202e541bd2c95bc023e820a022322f
immediateload lazy relationships named in refresh.attribute_names

The :meth:`_orm.Session.refresh` method will now immediately load a
relationship-bound attribute that is explicitly named within the
:paramref:`_orm.Session.refresh.attribute_names` collection even if it is
currently linked to the "select" loader, which normally is a "lazy" loader
that does not fire off during a refresh. The "lazy loader" strategy will
now detect that the operation is specifically a user-initiated
:meth:`_orm.Session.refresh` operation which named this attribute
explicitly, and will then call upon the "immediateload" strategy to
actually emit SQL to load the attribute. This should be helpful in
particular for some asyncio situations where the loading of an unloaded
lazy-loaded attribute must be forced, without using the actual lazy-loading
attribute pattern not supported in asyncio.

Fixes: #9298
Change-Id: I9b50f339bdf06cdb2ec98f8e5efca2b690895dd7
doc/build/changelog/unreleased_20/9298.rst [new file with mode: 0644]
doc/build/orm/extensions/asyncio.rst
lib/sqlalchemy/orm/context.py
lib/sqlalchemy/orm/loading.py
lib/sqlalchemy/orm/scoping.py
lib/sqlalchemy/orm/session.py
lib/sqlalchemy/orm/strategies.py
test/ext/asyncio/test_session_py3k.py
test/orm/test_expire.py