summaryrefslogtreecommitdiff
path: root/test/ext/test_declarative.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2010-10-21 16:54:39 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2010-10-21 16:54:39 -0400
commitc5579f77e26e1449f82888c4a95466a77642130d (patch)
tree917d2c8578b353a85f89ed9793a0235e1dcb15e6 /test/ext/test_declarative.py
parentee345b055c2c0c44a6cee4f14f70ebb5e4725aab (diff)
downloadsqlalchemy-c5579f77e26e1449f82888c4a95466a77642130d.tar.gz
- A mixin can now specify a column that overrides
a column of the same name associated with a superclass. Thanks to Oystein Haaland.
Diffstat (limited to 'test/ext/test_declarative.py')
-rw-r--r--test/ext/test_declarative.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/test/ext/test_declarative.py b/test/ext/test_declarative.py
index 0a6b17e27..72e2edf30 100644
--- a/test/ext/test_declarative.py
+++ b/test/ext/test_declarative.py
@@ -2170,7 +2170,28 @@ class DeclarativeMixinTest(DeclarativeTestBase):
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: