summaryrefslogtreecommitdiff
path: root/test/orm/inheritance/test_basic.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2009-07-25 19:42:15 +0000
committerMike Bayer <mike_mp@zzzcomputing.com>2009-07-25 19:42:15 +0000
commit818c9a617eafd97b05fe7c1d14e3bd7683a39e93 (patch)
tree12591e304767b0ebfcfee4a1c2ef44dfdd16ebd3 /test/orm/inheritance/test_basic.py
parent4d036d6dd4a6dde9e7ae18ebc6451fdf8da0c726 (diff)
downloadsqlalchemy-818c9a617eafd97b05fe7c1d14e3bd7683a39e93.tar.gz
- Using False or 0 as a polymorphic discriminator now
works on the base class as well as a subclass. [ticket:1440]
Diffstat (limited to 'test/orm/inheritance/test_basic.py')
-rw-r--r--test/orm/inheritance/test_basic.py30
1 files changed, 23 insertions, 7 deletions
diff --git a/test/orm/inheritance/test_basic.py b/test/orm/inheritance/test_basic.py
index 213f2ebf4..d2cf50d84 100644
--- a/test/orm/inheritance/test_basic.py
+++ b/test/orm/inheritance/test_basic.py
@@ -72,20 +72,36 @@ class FalseDiscriminatorTest(_base.MappedTest):
@classmethod
def define_tables(cls, metadata):
global t1
- t1 = Table('t1', metadata, Column('id', Integer, primary_key=True), Column('type', Integer, nullable=False))
+ t1 = Table('t1', metadata,
+ Column('id', Integer, primary_key=True),
+ Column('type', Integer, nullable=False)
+ )
- def test_false_discriminator(self):
+ def test_false_on_sub(self):
class Foo(object):pass
class Bar(Foo):pass
- mapper(Foo, t1, polymorphic_on=t1.c.type, polymorphic_identity=1)
- mapper(Bar, inherits=Foo, polymorphic_identity=0)
+ mapper(Foo, t1, polymorphic_on=t1.c.type, polymorphic_identity=True)
+ mapper(Bar, inherits=Foo, polymorphic_identity=False)
sess = create_session()
- f1 = Bar()
- sess.add(f1)
+ b1 = Bar()
+ sess.add(b1)
sess.flush()
- assert f1.type == 0
+ assert b1.type is False
sess.expunge_all()
assert isinstance(sess.query(Foo).one(), Bar)
+
+ def test_false_on_base(self):
+ class Ding(object):pass
+ class Bat(Ding):pass
+ mapper(Ding, t1, polymorphic_on=t1.c.type, polymorphic_identity=False)
+ mapper(Bat, inherits=Ding, polymorphic_identity=True)
+ sess = create_session()
+ d1 = Ding()
+ sess.add(d1)
+ sess.flush()
+ assert d1.type is False
+ sess.expunge_all()
+ assert sess.query(Ding).one() is not None
class PolymorphicSynonymTest(_base.MappedTest):
@classmethod