summaryrefslogtreecommitdiff
path: root/test
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 /test
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 'test')
-rw-r--r--test/ext/test_baked.py24
1 files changed, 24 insertions, 0 deletions
diff --git a/test/ext/test_baked.py b/test/ext/test_baked.py
index dcf333184..7004358fc 100644
--- a/test/ext/test_baked.py
+++ b/test/ext/test_baked.py
@@ -271,6 +271,30 @@ class LikeQueryTest(BakedTest):
eq_(u2.name, 'chuck')
self.assert_sql_count(testing.db, go, 0)
+ def test_get_includes_getclause(self):
+ # test issue #3597
+ User = self.classes.User
+
+ bq = self.bakery(lambda s: s.query(User))
+
+ for i in range(5):
+ sess = Session()
+ u1 = bq(sess).get(7)
+ eq_(u1.name, 'jack')
+
+ eq_(len(bq._bakery), 2)
+
+ # simulate race where mapper._get_clause
+ # may be generated more than once
+ from sqlalchemy import inspect
+ del inspect(User).__dict__['_get_clause']
+
+ for i in range(5):
+ sess = Session()
+ u1 = bq(sess).get(7)
+ eq_(u1.name, 'jack')
+ eq_(len(bq._bakery), 4)
+
class ResultTest(BakedTest):
__backend__ = True