From ec3e6c7dc2c03849b140c17e17e1efdc2f932a4a Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Tue, 28 Sep 2010 12:43:36 -0400 Subject: - Fixed bug whereby columns on a mixin wouldn't propagate correctly to a single-table inheritance scheme where the attribute name is different than that of the column. [ticket:1930]. Note [ticket:1931] which is the same issue for joined inh, not yet resolved. --- lib/sqlalchemy/ext/declarative.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'lib/sqlalchemy/ext/declarative.py') diff --git a/lib/sqlalchemy/ext/declarative.py b/lib/sqlalchemy/ext/declarative.py index cbda848e8..211b6724a 100755 --- a/lib/sqlalchemy/ext/declarative.py +++ b/lib/sqlalchemy/ext/declarative.py @@ -938,7 +938,10 @@ def _as_declarative(cls, classname, dict_): "on declarative mixin classes. ") if name not in dict_ and not ( '__table__' in dict_ and - name in dict_['__table__'].c + # TODO: coverage here when obj.name is not + # None and obj.name != name and obj.name in + # table.c + (obj.name or name) in dict_['__table__'].c ): potential_columns[name] = \ column_copies[obj] = \ @@ -960,7 +963,7 @@ def _as_declarative(cls, classname, dict_): # apply inherited columns as we should for k, v in potential_columns.items(): - if tablename or k not in parent_columns: + if tablename or (v.name or k) not in parent_columns: dict_[k] = v if inherited_table_args and not tablename: @@ -1087,7 +1090,7 @@ def _as_declarative(cls, classname, dict_): "Can't place __table_args__ on an inherited class " "with no table." ) - + # add any columns declared here to the inherited table. for c in cols: if c.primary_key: -- cgit v1.2.1