]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
- Fixed bug where "Can't add additional column" message
authorMike Bayer <mike_mp@zzzcomputing.com>
Mon, 2 Aug 2010 23:18:24 +0000 (19:18 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Mon, 2 Aug 2010 23:18:24 +0000 (19:18 -0400)
    would display the wrong name.

CHANGES
lib/sqlalchemy/ext/declarative.py
test/ext/test_declarative.py

diff --git a/CHANGES b/CHANGES
index 3d3bd724d53613691271e25309d5f262c5e59b91..836ccf20f431ef98a941a4866f81ad03e6992422 100644 (file)
--- 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.
index 7f9dacbb04c212486223a90e5501ff4a99ba5c24..712a563c3059452afe821c810976f9c1af7b9ebe 100755 (executable)
@@ -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:
index ef79b849ad1ef20fe817e80bef870a3b07b9b981..71e31233b8d786254db2239c917a886f7ddec08e 100644 (file)
@@ -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)