From 6de7db07cecd7f6f86452cdc64270c83b5bef212 Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Sat, 19 Jun 2010 13:25:37 -0400 Subject: - a mixin class can now define a column that matches one which is present on a __table__ defined on a subclass. It cannot, however, define one that is not present in the __table__, and the error message here now works. [ticket:1821] --- lib/sqlalchemy/ext/declarative.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'lib/sqlalchemy') diff --git a/lib/sqlalchemy/ext/declarative.py b/lib/sqlalchemy/ext/declarative.py index 8a28bb07c..385e0a309 100755 --- a/lib/sqlalchemy/ext/declarative.py +++ b/lib/sqlalchemy/ext/declarative.py @@ -645,7 +645,7 @@ def _as_declarative(cls, classname, dict_): mapper_args ={} table_args = inherited_table_args = None tablename = None - parent_columns = None + parent_columns = () for base in cls.__mro__: if _is_mapped_class(base): @@ -670,7 +670,9 @@ def _as_declarative(cls, classname, dict_): "Columns with foreign keys to other columns " "are not allowed on declarative mixins at this time." ) - if name not in dict_: + if name not in dict_ and not ( + '__table__' in dict_ and name in dict_['__table__'].c + ): potential_columns[name]=column_copies[obj]=obj.copy() elif isinstance(obj, RelationshipProperty): raise exceptions.InvalidRequestError( -- cgit v1.2.1