From b0308a7b3af91cc61fbe3347376024ad8b7be019 Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Sun, 29 Nov 2015 11:42:55 -0500 Subject: - 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 --- lib/sqlalchemy/ext/baked.py | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'lib/sqlalchemy') 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([ -- cgit v1.2.1