summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2015-11-29 11:42:55 -0500
committerMike Bayer <mike_mp@zzzcomputing.com>2015-11-29 11:42:55 -0500
commitb0308a7b3af91cc61fbe3347376024ad8b7be019 (patch)
tree9ea6e04086f85d8a9bd9855a9e7531b95db67368 /lib
parentc90f0a49f332867f6b337c79ddf192299788667f (diff)
downloadsqlalchemy-b0308a7b3af91cc61fbe3347376024ad8b7be019.tar.gz
- Fixed an issue in baked queries where the .get() method, used either
directly or within lazy loads, didn't consider the mapper's "get clause" as part of the cache key, causing bound parameter mismatches if the clause got re-generated. This clause is cached by mappers on the fly but in highly concurrent scenarios may be generated more than once when first accessed. fixes #3597
Diffstat (limited to 'lib')
-rw-r--r--lib/sqlalchemy/ext/baked.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/lib/sqlalchemy/ext/baked.py b/lib/sqlalchemy/ext/baked.py
index ee9f6f9bb..eb0c36805 100644
--- a/lib/sqlalchemy/ext/baked.py
+++ b/lib/sqlalchemy/ext/baked.py
@@ -354,6 +354,12 @@ class Result(object):
# (remember, we can map to an OUTER JOIN)
bq = self.bq
+ # add the clause we got from mapper._get_clause to the cache
+ # key so that if a race causes multiple calls to _get_clause,
+ # we've cached on ours
+ bq = bq._clone()
+ bq._cache_key += (_get_clause, )
+
bq = bq.with_criteria(setup, tuple(elem is None for elem in ident))
params = dict([