summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/sql/annotation.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2021-03-26 10:37:21 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2021-03-26 13:01:05 -0400
commit56f9c7743e9083add69a10501a503f4e25bb59d7 (patch)
tree43debd5fd0b2d90df87975d7c85d36a5e20da328 /lib/sqlalchemy/sql/annotation.py
parent784d32edff03cd960d0c47768f7ef0d0a438463e (diff)
downloadsqlalchemy-56f9c7743e9083add69a10501a503f4e25bb59d7.tar.gz
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
Diffstat (limited to 'lib/sqlalchemy/sql/annotation.py')
-rw-r--r--lib/sqlalchemy/sql/annotation.py2
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/sqlalchemy/sql/annotation.py b/lib/sqlalchemy/sql/annotation.py
index 8e5cdf148..2436c9c3f 100644
--- a/lib/sqlalchemy/sql/annotation.py
+++ b/lib/sqlalchemy/sql/annotation.py
@@ -262,7 +262,7 @@ def _deep_annotate(element, annotations, exclude=None):
and hasattr(elem, "proxy_set")
and elem.proxy_set.intersection(exclude)
):
- newelem = elem._clone()
+ newelem = elem._clone(**kw)
elif annotations != elem._annotations:
newelem = elem._annotate(annotations)
else: