summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/sql/elements.py
diff options
context:
space:
mode:
Diffstat (limited to 'lib/sqlalchemy/sql/elements.py')
-rw-r--r--lib/sqlalchemy/sql/elements.py25
1 files changed, 6 insertions, 19 deletions
diff --git a/lib/sqlalchemy/sql/elements.py b/lib/sqlalchemy/sql/elements.py
index ae105428c..e883454de 100644
--- a/lib/sqlalchemy/sql/elements.py
+++ b/lib/sqlalchemy/sql/elements.py
@@ -790,23 +790,14 @@ class ColumnElement(
"""
- _resolve_label = None
- """The name that should be used to identify this ColumnElement in a
- select() object when "label resolution" logic is used; this refers
- to using a string name in an expression like order_by() or group_by()
- that wishes to target a labeled expression in the columns clause.
+ _allow_label_resolve = True
+ """A flag that can be flipped to prevent a column from being resolvable
+ by string label name.
- The name is distinct from that of .name or ._label to account for the case
- where anonymizing logic may be used to change the name that's actually
- rendered at compile time; this attribute should hold onto the original
- name that was user-assigned when producing a .label() construct.
+ The joined eager loader strategy in the ORM uses this, for example.
"""
- _allow_label_resolve = True
- """A flag that can be flipped to prevent a column from being resolvable
- by string label name."""
-
_is_implicitly_boolean = False
_alt_names = ()
@@ -1783,7 +1774,7 @@ class TextClause(
# help in those cases where text() is
# interpreted in a column expression situation
- key = _label = _resolve_label = None
+ key = _label = None
_allow_label_resolve = False
@@ -4533,10 +4524,6 @@ class Label(roles.LabeledColumnExprRole, ColumnElement):
if name:
self.name = name
-
- # TODO: nothing fails if this is removed. this is related
- # to the order_by() string feature tested in test_text.py.
- self._resolve_label = self.name
else:
self.name = _anonymous_label.safe_construct(
id(self), getattr(element, "name", "anon")
@@ -4601,7 +4588,7 @@ class Label(roles.LabeledColumnExprRole, ColumnElement):
self._reset_memoizations()
self._element = clone(self._element, **kw)
if anonymize_labels:
- self.name = self._resolve_label = _anonymous_label.safe_construct(
+ self.name = _anonymous_label.safe_construct(
id(self), getattr(self.element, "name", "anon")
)
self.key = self._tq_label = self._tq_key_label = self.name