]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commit
send user defined options from the current query
authorMike Bayer <mike_mp@zzzcomputing.com>
Tue, 17 Aug 2021 19:03:57 +0000 (15:03 -0400)
committermike bayer <mike_mp@zzzcomputing.com>
Tue, 17 Aug 2021 19:15:30 +0000 (19:15 +0000)
commit29485026e9ea6500ea451b1d4a6f66795a02428d
tree7fc54d5815fbe77158ad99868081a530111aa1a7
parenta7899c44ba15076df8869f5b40d720ccf09d5273
send user defined options from the current query

Revised the means by which the
:attr:`_orm.ORMExecuteState.user_defined_options` accessor receives
:class:`_orm.UserDefinedOption` and related option objects from the
context, with particular emphasis on the "selectinload" on the loader
strategy where this previously was not working; other strategies did not
have this problem. The objects that are associated with the current query
being executed, and not that of a query being cached, are now propagated
unconditionally. This essentially separates them out from the "loader
strategy" options which are explicitly associated with the compiled state
of a query and need to be used in relation to the cached query.

The effect of this fix is that a user-defined option, such as those used
by the dogpile.caching example as well as for other recipes such as
defining a "shard id" for the horizontal sharing extension, will be
correctly propagated to eager and lazy loaders regardless of whether
a cached query was ultimately invoked.

Fixes: #6887
Change-Id: Ieaae5b01c85de26ea732ebd625e6e5823a470492
doc/build/changelog/unreleased_14/6887.rst [new file with mode: 0644]
lib/sqlalchemy/orm/__init__.py
lib/sqlalchemy/orm/strategies.py
lib/sqlalchemy/testing/fixtures.py
test/orm/test_events.py