summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2022-08-17 13:06:51 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2022-08-17 13:06:51 -0400
commita58f1b9c698dc7be29d43f2c4c21de8918943f77 (patch)
tree7a7af81748ea08cea45170594f26446737494d54 /lib
parent0eea54e84df104ffe8bc246eb82e4a7a2cf05079 (diff)
downloadsqlalchemy-a58f1b9c698dc7be29d43f2c4c21de8918943f77.tar.gz
fill out all distinguising fields for AliasedInsp
Hardened the cache key strategy for the :func:`_orm.aliased` and :func:`_orm.with_polymorphic` constructs. While no issue involving actual statements being cached can easily be demonstrated (if at all), these two constructs were not including enough of what makes them unique in their cache keys for caching on the aliased construct alone to be accurate. Fixes: #8401 Change-Id: I13d14985b6965f398edd9494601d8ae89ac641f2
Diffstat (limited to 'lib')
-rw-r--r--lib/sqlalchemy/orm/util.py19
1 files changed, 13 insertions, 6 deletions
diff --git a/lib/sqlalchemy/orm/util.py b/lib/sqlalchemy/orm/util.py
index 02080a27f..9a5399af0 100644
--- a/lib/sqlalchemy/orm/util.py
+++ b/lib/sqlalchemy/orm/util.py
@@ -748,6 +748,19 @@ class AliasedInsp(
"_nest_adapters",
)
+ _cache_key_traversal = [
+ ("name", visitors.ExtendedInternalTraversal.dp_string),
+ ("_adapt_on_names", visitors.ExtendedInternalTraversal.dp_boolean),
+ ("_use_mapper_path", visitors.ExtendedInternalTraversal.dp_boolean),
+ ("_target", visitors.ExtendedInternalTraversal.dp_inspectable),
+ ("selectable", visitors.ExtendedInternalTraversal.dp_clauseelement),
+ (
+ "with_polymorphic_mappers",
+ visitors.InternalTraversal.dp_has_cache_key_list,
+ ),
+ ("polymorphic_on", visitors.InternalTraversal.dp_clauseelement),
+ ]
+
mapper: Mapper[_O]
selectable: FromClause
_adapter: sql_util.ColumnAdapter
@@ -940,12 +953,6 @@ class AliasedInsp(
def entity_namespace(self) -> AliasedClass[_O]:
return self.entity
- _cache_key_traversal = [
- ("name", visitors.ExtendedInternalTraversal.dp_string),
- ("_adapt_on_names", visitors.ExtendedInternalTraversal.dp_boolean),
- ("selectable", visitors.ExtendedInternalTraversal.dp_clauseelement),
- ]
-
@property
def class_(self) -> Type[_O]:
"""Return the mapped class ultimately represented by this