From 14250f2668151f1c4df86dbf962c771e9788111e Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Wed, 1 Jun 2022 12:11:19 -0400 Subject: propagate proxy_key from WrapsColumnExpression this allows cast() of a label() to propagate the proxy key outwards in the same way that it apparently works at the SQL level. This is stuffing even more rules into naming so basically seeing how far we can go without other cases starting to fail. Fixes: #8084 Change-Id: I20bd97dae798fee6492334c06934e807d0f269ef --- lib/sqlalchemy/sql/elements.py | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'lib/sqlalchemy/sql') diff --git a/lib/sqlalchemy/sql/elements.py b/lib/sqlalchemy/sql/elements.py index 61c5379d8..f9ede8a71 100644 --- a/lib/sqlalchemy/sql/elements.py +++ b/lib/sqlalchemy/sql/elements.py @@ -1768,6 +1768,14 @@ class WrapsColumnExpression(ColumnElement[_T]): else: return self._dedupe_anon_tq_label_idx(idx) + @property + def _proxy_key(self): + wce = self.wrapped_column_expression + + if not wce._is_text_clause: + return wce._proxy_key + return super()._proxy_key + SelfBindParameter = TypeVar("SelfBindParameter", bound="BindParameter[Any]") -- cgit v1.2.1