summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/sql/cache_key.py
diff options
context:
space:
mode:
authormike bayer <mike_mp@zzzcomputing.com>2022-11-11 21:30:43 +0000
committerGerrit Code Review <gerrit@ci3.zzzcomputing.com>2022-11-11 21:30:43 +0000
commit6b140afe7db3456c995f50bacaca69112db72d70 (patch)
tree6163a6e3f4a5dd78073a82151c96e351a541c6a5 /lib/sqlalchemy/sql/cache_key.py
parent1dd0f23e8d74aa7edc8dd309093a95171e2e8f09 (diff)
parent1d8833a9c1ada64cfc716109a8836b32cb8a9bd6 (diff)
downloadsqlalchemy-6b140afe7db3456c995f50bacaca69112db72d70.tar.gz
Merge "ensure anon_map is passed for most annotated traversals" into main
Diffstat (limited to 'lib/sqlalchemy/sql/cache_key.py')
-rw-r--r--lib/sqlalchemy/sql/cache_key.py17
1 files changed, 11 insertions, 6 deletions
diff --git a/lib/sqlalchemy/sql/cache_key.py b/lib/sqlalchemy/sql/cache_key.py
index 88148285c..39d09d3ab 100644
--- a/lib/sqlalchemy/sql/cache_key.py
+++ b/lib/sqlalchemy/sql/cache_key.py
@@ -297,12 +297,17 @@ class HasCacheKey:
else None,
)
elif meth is InternalTraversal.dp_annotations_key:
- # obj is here is the _annotations dict. however, we
- # want to use the memoized cache key version of it. for
- # Columns, this should be long lived. For select()
- # statements, not so much, but they usually won't have
- # annotations.
- result += self._annotations_cache_key # type: ignore
+ # obj is here is the _annotations dict. Table uses
+ # a memoized version of it. however in other cases,
+ # we generate it given anon_map as we may be from a
+ # Join, Aliased, etc.
+ # see #8790
+
+ if self._gen_static_annotations_cache_key: # type: ignore # noqa: E501
+ result += self._annotations_cache_key # type: ignore # noqa: E501
+ else:
+ result += self._gen_annotations_cache_key(anon_map) # type: ignore # noqa: E501
+
elif (
meth is InternalTraversal.dp_clauseelement_list
or meth is InternalTraversal.dp_clauseelement_tuple