From: Mike Bayer Date: Mon, 2 Aug 2010 23:18:24 +0000 (-0400) Subject: - Fixed bug where "Can't add additional column" message X-Git-Tag: rel_0_6_4~62 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=31a28392d1ebfd04870506d182b1a6bc5f2101c5;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git - Fixed bug where "Can't add additional column" message would display the wrong name. --- diff --git a/CHANGES b/CHANGES index 3d3bd724d5..836ccf20f4 100644 --- a/CHANGES +++ b/CHANGES @@ -83,7 +83,10 @@ CHANGES isn't a mixin - evaluation is at the same time as if @classproperty weren't used. But here we at least allow it to function as expected. - + + - Fixed bug where "Can't add additional column" message + would display the wrong name. + - mssql - Fixed "default schema" query to work with pymssql backend. diff --git a/lib/sqlalchemy/ext/declarative.py b/lib/sqlalchemy/ext/declarative.py index 7f9dacbb04..712a563c30 100755 --- a/lib/sqlalchemy/ext/declarative.py +++ b/lib/sqlalchemy/ext/declarative.py @@ -928,6 +928,7 @@ def _as_declarative(cls, classname, dict_): cls._decl_class_registry[classname] = cls our_stuff = util.OrderedDict() + for k in dict_: value = dict_[k] if isinstance(value, util.classproperty): @@ -998,7 +999,7 @@ def _as_declarative(cls, classname, dict_): if not table.c.contains_column(c): raise exceptions.ArgumentError( "Can't add additional column %r when " - "specifying __table__" % key + "specifying __table__" % c.key ) if 'inherits' not in mapper_args: diff --git a/test/ext/test_declarative.py b/test/ext/test_declarative.py index ef79b849ad..71e31233b8 100644 --- a/test/ext/test_declarative.py +++ b/test/ext/test_declarative.py @@ -2619,17 +2619,18 @@ class DeclarativeMixinTest(DeclarativeTestBase): def test_table_in_model_and_different_named_column_in_mixin(self): class ColumnMixin: - tada = Column(Integer) - + + def go(): class Model(Base, ColumnMixin): - __table__ = Table('foo', Base.metadata, Column('data', - Integer), Column('id', Integer, - primary_key=True)) - + __table__ = Table('foo', Base.metadata, + Column('data',Integer), + Column('id', Integer,primary_key=True)) + foo = relationship("Dest") + assert_raises_message(sa.exc.ArgumentError, "Can't add additional column 'tada' when " "specifying __table__", go)