From 9586594754cef19bf1e2e14b7e70876efefdafbe Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Wed, 30 Sep 2020 08:37:57 -0400 Subject: raise on lower-case column shared to multiple tables Fixed bug where an error was not raised for lower-case :func:`_column` added to lower-case :func:`_table` object. This now raises :class:`_exc.ArgumentError` which has always been the case for upper-case :class:`_schema.Column` and :class:`_schema.Table`. Fixes: #5618 Change-Id: Ifcbdf27c022fd2996a5b99559df71fc1c1e0f19c --- test/sql/test_metadata.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'test/sql') diff --git a/test/sql/test_metadata.py b/test/sql/test_metadata.py index ebcde3c63..d378c8184 100644 --- a/test/sql/test_metadata.py +++ b/test/sql/test_metadata.py @@ -8,6 +8,7 @@ from sqlalchemy import BLANK_SCHEMA from sqlalchemy import Boolean from sqlalchemy import CheckConstraint from sqlalchemy import Column +from sqlalchemy import column from sqlalchemy import ColumnDefault from sqlalchemy import desc from sqlalchemy import Enum @@ -24,6 +25,7 @@ from sqlalchemy import schema from sqlalchemy import Sequence from sqlalchemy import String from sqlalchemy import Table +from sqlalchemy import table from sqlalchemy import testing from sqlalchemy import text from sqlalchemy import TypeDecorator @@ -3694,7 +3696,7 @@ class ColumnDefinitionTest(AssertsCompiledSQL, fixtures.TestBase): c, ) - def test_dupe_column(self): + def test_no_shared_column_schema(self): c = Column("x", Integer) Table("t", MetaData(), c) @@ -3707,6 +3709,18 @@ class ColumnDefinitionTest(AssertsCompiledSQL, fixtures.TestBase): c, ) + def test_no_shared_column_sql(self): + c = column("x", Integer) + table("t", c) + + assert_raises_message( + exc.ArgumentError, + "column object 'x' already assigned to table 't'", + table, + "q", + c, + ) + def test_incomplete_key(self): c = Column(Integer) assert c.name is None -- cgit v1.2.1