diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2012-09-14 21:58:19 -0400 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2012-09-14 21:58:19 -0400 |
| commit | 062f0a202af1185a21b94f33cb7af92cffacfd15 (patch) | |
| tree | e7b05b753cb4e35f6d96ad245ff1d6b55439580f /lib/sqlalchemy/ext | |
| parent | b585b9b56eb809b65df545e6852c8ee6cfe12c6a (diff) | |
| download | sqlalchemy-062f0a202af1185a21b94f33cb7af92cffacfd15.tar.gz | |
- [bug] Fixed a disconnect that slowly evolved
between a @declared_attr Column and a
directly-defined Column on a mixin. In both
cases, the Column will be applied to the
declared class' table, but not to that of a
joined inheritance subclass. Previously,
the directly-defined Column would be placed
on both the base and the sub table, which isn't
typically what's desired. [ticket:2565]
Diffstat (limited to 'lib/sqlalchemy/ext')
| -rw-r--r-- | lib/sqlalchemy/ext/declarative/base.py | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/sqlalchemy/ext/declarative/base.py b/lib/sqlalchemy/ext/declarative/base.py index 40c8c6ef6..8e8f5626c 100644 --- a/lib/sqlalchemy/ext/declarative/base.py +++ b/lib/sqlalchemy/ext/declarative/base.py @@ -98,6 +98,11 @@ def _as_declarative(cls, classname, dict_): elif base is not cls: # we're a mixin. if isinstance(obj, Column): + if getattr(cls, name) is not obj: + # if column has been overridden + # (like by the InstrumentedAttribute of the + # superclass), skip + continue if obj.foreign_keys: raise exc.InvalidRequestError( "Columns with foreign keys to other columns " @@ -127,8 +132,7 @@ def _as_declarative(cls, classname, dict_): # apply inherited columns as we should for k, v in potential_columns.items(): - if tablename or (v.name or k) not in parent_columns: - dict_[k] = v + dict_[k] = v if inherited_table_args and not tablename: table_args = None |
