summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2019-02-19 19:46:17 -0500
committerMike Bayer <mike_mp@zzzcomputing.com>2019-02-19 19:46:17 -0500
commitd71f34cb2a28e8dfc410bc5bec68372be6d7c333 (patch)
tree975747f157b1df1f36c7ee7ec4bf019afb55dff8 /lib
parentc0bd36873b3879747f2d094696fb0bc19c0539ff (diff)
downloadsqlalchemy-d71f34cb2a28e8dfc410bc5bec68372be6d7c333.tar.gz
Ensure _simple_lazy_clause bind names are fixed before cloning
Fixed a regression in 1.2 due to the introduction of baked queries for relationship lazy loaders, where a race condition is created during the generation of the "lazy clause" which occurs within a memoized attribute. If two threads initialize the memoized attribute concurrently, the baked query could be generated with bind parameter keys that are then replaced with new keys by the next run, leading to a lazy load query that specifies the related criteria as ``None``. The fix establishes that the parameter names are fixed before the new clause and parameter objects are generated, so that the names are the same every time. Fixes: #4507 Change-Id: I605b824e028c87bc20ca8c2577227cdf6a591064
Diffstat (limited to 'lib')
-rw-r--r--lib/sqlalchemy/orm/strategies.py3
1 files changed, 3 insertions, 0 deletions
diff --git a/lib/sqlalchemy/orm/strategies.py b/lib/sqlalchemy/orm/strategies.py
index 3e7372fac..ec3c9790f 100644
--- a/lib/sqlalchemy/orm/strategies.py
+++ b/lib/sqlalchemy/orm/strategies.py
@@ -595,6 +595,9 @@ class LazyLoader(AbstractRelationshipLoader, util.MemoizedSlots):
def visit_bindparam(bindparam):
bindparam.unique = False
+ visitors.traverse(criterion, {}, {"bindparam": visit_bindparam})
+
+ def visit_bindparam(bindparam):
if bindparam._identifying_key in bind_to_col:
params.append(
(