summaryrefslogtreecommitdiff
path: root/test/orm/inheritance/test_basic.py
diff options
context:
space:
mode:
Diffstat (limited to 'test/orm/inheritance/test_basic.py')
-rw-r--r--test/orm/inheritance/test_basic.py52
1 files changed, 50 insertions, 2 deletions
diff --git a/test/orm/inheritance/test_basic.py b/test/orm/inheritance/test_basic.py
index c9aa5fc9b..dab2d5639 100644
--- a/test/orm/inheritance/test_basic.py
+++ b/test/orm/inheritance/test_basic.py
@@ -186,19 +186,62 @@ class PolymorphicOnNotLocalTest(fixtures.MappedTest):
self._roundtrip()
- def test_polymorphic_on_expr_implicit_map(self):
+ def test_polymorphic_on_expr_implicit_map_no_label_joined(self):
t2, t1 = self.tables.t2, self.tables.t1
Parent, Child = self.classes.Parent, self.classes.Child
expr = case([
(t1.c.x=="p", "parent"),
(t1.c.x=="c", "child"),
- ],else_ = t1.c.x).label("foo")
+ ],else_ = t1.c.x)
+ mapper(Parent, t1, polymorphic_identity="parent",
+ polymorphic_on=expr)
+ mapper(Child, t2, inherits=Parent, polymorphic_identity="child")
+
+ self._roundtrip()
+
+ def test_polymorphic_on_expr_implicit_map_w_label_joined(self):
+ t2, t1 = self.tables.t2, self.tables.t1
+ Parent, Child = self.classes.Parent, self.classes.Child
+ expr = case([
+ (t1.c.x=="p", "parent"),
+ (t1.c.x=="c", "child"),
+ ],else_ = t1.c.x).label(None)
mapper(Parent, t1, polymorphic_identity="parent",
polymorphic_on=expr)
mapper(Child, t2, inherits=Parent, polymorphic_identity="child")
self._roundtrip()
+ def test_polymorphic_on_expr_implicit_map_no_label_single(self):
+ """test that single_table_criterion is propagated
+ with a standalone expr"""
+ t2, t1 = self.tables.t2, self.tables.t1
+ Parent, Child = self.classes.Parent, self.classes.Child
+ expr = case([
+ (t1.c.x=="p", "parent"),
+ (t1.c.x=="c", "child"),
+ ],else_ = t1.c.x)
+ mapper(Parent, t1, polymorphic_identity="parent",
+ polymorphic_on=expr)
+ mapper(Child, inherits=Parent, polymorphic_identity="child")
+
+ self._roundtrip()
+
+ def test_polymorphic_on_expr_implicit_map_w_label_single(self):
+ """test that single_table_criterion is propagated
+ with a standalone expr"""
+ t2, t1 = self.tables.t2, self.tables.t1
+ Parent, Child = self.classes.Parent, self.classes.Child
+ expr = case([
+ (t1.c.x=="p", "parent"),
+ (t1.c.x=="c", "child"),
+ ],else_ = t1.c.x).label(None)
+ mapper(Parent, t1, polymorphic_identity="parent",
+ polymorphic_on=expr)
+ mapper(Child, inherits=Parent, polymorphic_identity="child")
+
+ self._roundtrip()
+
def test_polymorphic_on_column_prop(self):
t2, t1 = self.tables.t2, self.tables.t1
Parent, Child = self.classes.Parent, self.classes.Child
@@ -269,6 +312,11 @@ class PolymorphicOnNotLocalTest(fixtures.MappedTest):
[Parent, Child, Parent]
)
+ eq_(
+ [type(t) for t in s.query(Child).all()],
+ [Child]
+ )
+
class FalseDiscriminatorTest(fixtures.MappedTest):
@classmethod