Same thing, but moving there since it is more of a
"marker" that's specific to declararative,
not just an attribute technique. [ticket:1915]
-
+
+ - 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.
+
- engine
- Fixed a regression in 0.6.4 whereby the change that
"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] = \
# 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:
"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:
# 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)
assert Specific.__table__ is General.__table__
eq_(General.__table__.kwargs, {'mysql_engine': 'InnoDB'})
+ def test_columns_single_table_inheritance(self):
+ class MyMixin(object):
+ foo = Column('foo', Integer)
+ bar = Column('bar_newname', Integer)
+
+ class General(Base, MyMixin):
+ __tablename__ = 'test'
+ id = Column(Integer, primary_key=True)
+ type_ = Column(String(50))
+ __mapper__args = {'polymorphic_on': type_}
+
+ class Specific(General):
+ __mapper_args__ = {'polymorphic_identity': 'specific'}
+
+ @testing.fails_if(lambda: True, "Unhandled declarative use case")
+ def test_columns_joined_table_inheritance(self):
+ class MyMixin(object):
+ foo = Column('foo', Integer)
+ bar = Column('bar_newname', Integer)
+
+ class General(Base, MyMixin):
+ __tablename__ = 'test'
+ id = Column(Integer, primary_key=True)
+ type_ = Column(String(50))
+ __mapper__args = {'polymorphic_on': type_}
+
+ class Specific(General):
+ __tablename__ = 'sub'
+ id = Column(Integer, ForeignKey('test.id'), primary_key=True)
+ __mapper_args__ = {'polymorphic_identity': 'specific'}
+
def test_table_args_overridden(self):
class MyMixin: