inheritance scheme where the attribute name is
different than that of the column. [ticket:1930],
[ticket:1931].
-
+
+ - A mixin can now specify a column that overrides
+ a column of the same name associated with a superclass.
+ Thanks to Oystein Haaland.
+
- engine
- Fixed a regression in 0.6.4 whereby the change that
if name not in dict_ and not (
'__table__' in dict_ and
(obj.name or name) in dict_['__table__'].c
- ):
+ ) and name not in potential_columns:
potential_columns[name] = \
column_copies[obj] = \
obj.copy()
eq_(obj.name, 'testing')
eq_(obj.foo(), 'bar1')
eq_(obj.baz, 'fu')
+
+ def test_mixin_overrides(self):
+ """test a mixin that overrides a column on a superclass."""
+
+ class MixinA(object):
+ foo = Column(String(50))
+
+ class MixinB(MixinA):
+ foo = Column(Integer)
+ class MyModelA(Base, MixinA):
+ __tablename__ = 'testa'
+ id = Column(Integer, primary_key=True)
+
+ class MyModelB(Base, MixinB):
+ __tablename__ = 'testb'
+ id = Column(Integer, primary_key=True)
+
+ eq_(MyModelA.__table__.c.foo.type.__class__, String)
+ eq_(MyModelB.__table__.c.foo.type.__class__, Integer)
+
+
def test_not_allowed(self):
class MyMixin: