]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commit
Adapt loader_criteria params for current query
authorMike Bayer <mike_mp@zzzcomputing.com>
Fri, 26 Mar 2021 14:37:21 +0000 (10:37 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Fri, 26 Mar 2021 17:01:05 +0000 (13:01 -0400)
commit56f9c7743e9083add69a10501a503f4e25bb59d7
tree43debd5fd0b2d90df87975d7c85d36a5e20da328
parent784d32edff03cd960d0c47768f7ef0d0a438463e
Adapt loader_criteria params for current query

Fixed critical issue in the new :meth:`_orm.PropComparator.and_` feature
where loader strategies that emit secondary SELECT statements such as
:func:`_orm.selectinload` and :func:`_orm.lazyload` would fail to
accommodate for bound parameters in the user-defined criteria in terms of
the current statement being executed, as opposed to the cached statement,
causing stale bound values to be used.

This also adds a warning for the case where an object that uses
:func:`_orm.lazyload` in conjunction with :meth:`_orm.PropComparator.and_`
is attempted to be serialized; the loader criteria cannot reliably
be serialized and deserialized and eager loading should be used for this
case.

Fixes: #6139
Change-Id: I5a638bbecb7b583db2d3c0b76469f5a25c13dd3b
doc/build/changelog/unreleased_14/6139.rst [new file with mode: 0644]
lib/sqlalchemy/orm/strategies.py
lib/sqlalchemy/orm/strategy_options.py
lib/sqlalchemy/sql/annotation.py
lib/sqlalchemy/sql/base.py
lib/sqlalchemy/sql/elements.py
lib/sqlalchemy/sql/traversals.py
lib/sqlalchemy/sql/visitors.py
test/orm/test_pickled.py
test/orm/test_relationship_criteria.py