summaryrefslogtreecommitdiff
path: root/test/orm/inheritance/test_basic.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2021-03-17 11:04:58 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2021-03-17 13:56:17 -0400
commit5f9c45400556f821550e7a39331f1bd5af5a34ce (patch)
treef35043d3f4e416eb3734908952da55caefcda994 /test/orm/inheritance/test_basic.py
parentecb392c5f927ab117f9704ce373bf2af1dbe5b69 (diff)
downloadsqlalchemy-5f9c45400556f821550e7a39331f1bd5af5a34ce.tar.gz
Use explicit names for mapper _get_clause parameters
Fixed a critical regression in the relationship lazy loader where the SQL criteria used to fetch a related many-to-one object could go stale in relation to other memoized structures within the loader if the mapper had configuration changes, such as can occur when mappers are late configured or configured on demand, producing a comparison to None and returning no object. Huge thanks to Alan Hamlett for their help tracking this down late into the night. The primary change is that mapper._get_clause() uses a fixed name for its bound parameters, which is memoized under a lambda statement in the case of many-to-one lazy loading. This has implications for some other logic namely the .compare() used by loader strategies to determine use_get needed to be adjusted. This change also repairs the lambda module's behavior of removing the "required" flag from bound parameters, which caused this issue to also fail silently rather than issuing an error for a required bind parameter. Fixes: #6055 Change-Id: I19e1aba9207a049873e0f13c19bad7541e223cfd
Diffstat (limited to 'test/orm/inheritance/test_basic.py')
-rw-r--r--test/orm/inheritance/test_basic.py20
1 files changed, 10 insertions, 10 deletions
diff --git a/test/orm/inheritance/test_basic.py b/test/orm/inheritance/test_basic.py
index d145fef79..8769d2b39 100644
--- a/test/orm/inheritance/test_basic.py
+++ b/test/orm/inheritance/test_basic.py
@@ -1616,8 +1616,8 @@ class PassiveDeletesTest(fixtures.MappedTest):
asserter.assert_(
CompiledSQL(
"SELECT a.id AS a_id, a.type AS a_type "
- "FROM a WHERE a.id = :param_1",
- [{"param_1": 1}],
+ "FROM a WHERE a.id = :pk_1",
+ [{"pk_1": 1}],
),
CompiledSQL("DELETE FROM a WHERE a.id = :id", [{"id": 1}]),
)
@@ -1658,8 +1658,8 @@ class PassiveDeletesTest(fixtures.MappedTest):
asserter.assert_(
CompiledSQL(
"SELECT a.id AS a_id, a.type AS a_type "
- "FROM a WHERE a.id = :param_1",
- [{"param_1": 1}],
+ "FROM a WHERE a.id = :pk_1",
+ [{"pk_1": 1}],
),
CompiledSQL("DELETE FROM a WHERE a.id = :id", [{"id": 1}]),
)
@@ -1696,8 +1696,8 @@ class PassiveDeletesTest(fixtures.MappedTest):
asserter.assert_(
CompiledSQL(
"SELECT a.id AS a_id, a.type AS a_type "
- "FROM a WHERE a.id = :param_1",
- [{"param_1": 1}],
+ "FROM a WHERE a.id = :pk_1",
+ [{"pk_1": 1}],
),
CompiledSQL("DELETE FROM a WHERE a.id = :id", [{"id": 1}]),
)
@@ -2549,8 +2549,8 @@ class OptimizedLoadTest(fixtures.MappedTest):
"base.data AS base_data, base.type AS base_type, "
"sub.sub AS sub_sub, sub.subcounter2 AS sub_subcounter2 "
"FROM base LEFT OUTER JOIN sub ON base.id = sub.id "
- "WHERE base.id = :param_1",
- {"param_1": sjb_id},
+ "WHERE base.id = :pk_1",
+ {"pk_1": sjb_id},
),
)
@@ -2804,8 +2804,8 @@ class OptimizedLoadTest(fixtures.MappedTest):
"SELECT base.counter AS base_counter, "
"sub.subcounter AS sub_subcounter, "
"sub.subcounter2 AS sub_subcounter2 FROM base JOIN sub "
- "ON base.id = sub.id WHERE base.id = :param_1",
- lambda ctx: {"param_1": s1.id},
+ "ON base.id = sub.id WHERE base.id = :pk_1",
+ lambda ctx: {"pk_1": s1.id},
),
)