From 4e3806861b19a00203f95b6ecbe411a4e252d152 Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Tue, 9 May 2023 11:33:30 -0400 Subject: allow column named twice warning to take effect Fixed issue in :func:`_orm.mapped_column` construct where the correct warning for "column X named directly multiple times" would not be emitted when ORM mapped attributes referred to the same :class:`_schema.Column`, if the :func:`_orm.mapped_column` construct were involved, raising an internal assertion instead. Fixes: #9630 Change-Id: I5d9dfaaa225aefb487c9cd981ba3ad78507bb577 --- lib/sqlalchemy/orm/decl_base.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/sqlalchemy/orm/decl_base.py b/lib/sqlalchemy/orm/decl_base.py index b7d6dd8cf..71b93de8f 100644 --- a/lib/sqlalchemy/orm/decl_base.py +++ b/lib/sqlalchemy/orm/decl_base.py @@ -1646,7 +1646,11 @@ class _ClassScanMapperConfig(_MapperConfig): if not isinstance(c, CompositeProperty): name_to_prop_key[col.name].add(key) declared_columns.add(col) - assert col not in column_ordering + + # we would assert this, however we want the below + # warning to take effect instead. See #9630 + # assert col not in column_ordering + column_ordering[col] = sort_order # if this is a MappedColumn and the attribute key we -- cgit v1.2.1