summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2010-09-28 12:43:36 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2010-09-28 12:43:36 -0400
commitec3e6c7dc2c03849b140c17e17e1efdc2f932a4a (patch)
treed82b8abf889248a00a18e4dc15508c380308e0f9 /lib/sqlalchemy
parentabc8e45b2f94dee88aa712b21470d65f942f12b2 (diff)
downloadsqlalchemy-ec3e6c7dc2c03849b140c17e17e1efdc2f932a4a.tar.gz
- 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.
Diffstat (limited to 'lib/sqlalchemy')
-rwxr-xr-xlib/sqlalchemy/ext/declarative.py9
-rw-r--r--lib/sqlalchemy/orm/attributes.py2
2 files changed, 7 insertions, 4 deletions
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:
diff --git a/lib/sqlalchemy/orm/attributes.py b/lib/sqlalchemy/orm/attributes.py
index b56de5f05..ddaf62c7f 100644
--- a/lib/sqlalchemy/orm/attributes.py
+++ b/lib/sqlalchemy/orm/attributes.py
@@ -399,7 +399,7 @@ class AttributeImpl(object):
# Return a new, empty value
return self.initialize(state, dict_)
-
+
def append(self, state, dict_, value, initiator, passive=PASSIVE_OFF):
self.set(state, dict_, value, initiator, passive=passive)