summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/sql/elements.py
diff options
context:
space:
mode:
authormike bayer <mike_mp@zzzcomputing.com>2021-07-09 21:29:40 +0000
committerGerrit Code Review <gerrit@ci3.zzzcomputing.com>2021-07-09 21:29:40 +0000
commitca52e87268fec966f6005b1e4aa30206ae895e9e (patch)
tree179bd2b61fbb50c114e0617e06913b8c5917357b /lib/sqlalchemy/sql/elements.py
parenta457e555e0b1cc8aca79270f2330b5fdef78eafb (diff)
parent4e1b2ee4cb345f499bdfbff6c393efbebd8e1e72 (diff)
downloadsqlalchemy-ca52e87268fec966f6005b1e4aa30206ae895e9e.tar.gz
Merge "Add additional support to honor _proxy_key in Core selects"
Diffstat (limited to 'lib/sqlalchemy/sql/elements.py')
-rw-r--r--lib/sqlalchemy/sql/elements.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/lib/sqlalchemy/sql/elements.py b/lib/sqlalchemy/sql/elements.py
index 73311f110..173314abe 100644
--- a/lib/sqlalchemy/sql/elements.py
+++ b/lib/sqlalchemy/sql/elements.py
@@ -887,6 +887,21 @@ class ColumnElement(
else:
return getattr(self, "name", "_no_label")
+ @util.memoized_property
+ def _expression_label(self):
+ """a suggested label to use in the case that the column has no name,
+ which should be used if possible as the explicit 'AS <label>'
+ where this expression would normally have an anon label.
+
+ """
+
+ if getattr(self, "name", None) is not None:
+ return None
+ elif self._annotations and "proxy_key" in self._annotations:
+ return self._annotations["proxy_key"]
+ else:
+ return None
+
def _make_proxy(
self, selectable, name=None, key=None, name_is_truncatable=False, **kw
):