--- /dev/null
+.. change::
+ :tags: bug, sql
+ :tickets: 5618
+
+ Fixed bug where an error was not raised for lower-case :func:`_sql.column`
+ added to lower-case :func:`_sql.table` object. This now raises
+ :class:`_exc.ArgumentError` which has always been the case for upper-case
+ :class:`_schema.Column` and :class:`_schema.Table`.
\ No newline at end of file
return self.name.encode("ascii", "backslashreplace")
def append_column(self, c):
+ existing = c.table
+ if existing is not None and existing is not self:
+ raise exc.ArgumentError(
+ "column object '%s' already assigned to table '%s'"
+ % (c.key, existing)
+ )
+
self._columns.add(c)
c.table = self
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
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
c,
)
- def test_dupe_column(self):
+ def test_no_shared_column_schema(self):
c = Column("x", Integer)
Table("t", MetaData(), c)
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