summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/sql
diff options
context:
space:
mode:
authormike bayer <mike_mp@zzzcomputing.com>2021-03-18 18:44:24 +0000
committerGerrit Code Review <gerrit@ci3.zzzcomputing.com>2021-03-18 18:44:24 +0000
commitb728ff1601336459840a7dcdab7697fa3535dbf5 (patch)
tree42753364bbb573c6a97ff1dc8ebec1ae115e2baf /lib/sqlalchemy/sql
parentbecf996e1d71b0778c1294fccc1b090b2f39a263 (diff)
parentdfce8c35d3f95c401957f4d0ddaf8c7f49f52ece (diff)
downloadsqlalchemy-b728ff1601336459840a7dcdab7697fa3535dbf5.tar.gz
Merge "Raise at Core / ORM concrete inh level for label overlap"
Diffstat (limited to 'lib/sqlalchemy/sql')
-rw-r--r--lib/sqlalchemy/sql/elements.py21
1 files changed, 15 insertions, 6 deletions
diff --git a/lib/sqlalchemy/sql/elements.py b/lib/sqlalchemy/sql/elements.py
index 29023c9fe..26c03b57b 100644
--- a/lib/sqlalchemy/sql/elements.py
+++ b/lib/sqlalchemy/sql/elements.py
@@ -4330,12 +4330,21 @@ class Label(roles.LabeledColumnExprRole, ColumnElement):
disallow_is_literal=True,
name_is_truncatable=isinstance(name, _truncated_label),
)
- # TODO: want to remove this assertion at some point. all
- # _make_proxy() implementations will give us back the key that
- # is our "name" in the first place. based on this we can
- # safely return our "self.key" as the key here, to support a new
- # case where the key and name are separate.
- assert key == self.name
+
+ # there was a note here to remove this assertion, which was here
+ # to determine if we later could support a use case where
+ # the key and name of a label are separate. But I don't know what
+ # that case was. For now, this is an unexpected case that occurs
+ # when a label name conflicts with other columns and select()
+ # is attempting to disambiguate an explicit label, which is not what
+ # the user would want. See issue #6090.
+ if key != self.name:
+ raise exc.InvalidRequestError(
+ "Label name %s is being renamed to an anonymous label due "
+ "to disambiguation "
+ "which is not supported right now. Please use unique names "
+ "for explicit labels." % (self.name)
+ )
e._propagate_attrs = selectable._propagate_attrs
e._proxies.append(self)