diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2013-06-30 15:58:50 -0400 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2013-06-30 15:58:50 -0400 |
commit | 715d6cf3d10a71acd7726b7e00c3ff40b4559bc7 (patch) | |
tree | 47b077618eb8fe099495fe79d7c55fe9c5faeca0 /test/orm/inheritance/test_basic.py | |
parent | 6ece305692399db8266fb028a9fe5f8a1af0295b (diff) | |
download | sqlalchemy-715d6cf3d10a71acd7726b7e00c3ff40b4559bc7.tar.gz |
- additional fix for [ticket:2750] where on an update, we make sure the
value is present
Diffstat (limited to 'test/orm/inheritance/test_basic.py')
-rw-r--r-- | test/orm/inheritance/test_basic.py | 35 |
1 files changed, 33 insertions, 2 deletions
diff --git a/test/orm/inheritance/test_basic.py b/test/orm/inheritance/test_basic.py index 99a008436..41a167e72 100644 --- a/test/orm/inheritance/test_basic.py +++ b/test/orm/inheritance/test_basic.py @@ -555,11 +555,12 @@ class PolymorphicAttributeManagementTest(fixtures.MappedTest): Table('table_b', metadata, Column('id', Integer, ForeignKey('table_a.id'), primary_key=True), - Column('class_name', String(50)) + Column('class_name', String(50)), ) Table('table_c', metadata, Column('id', Integer, ForeignKey('table_b.id'), - primary_key=True) + primary_key=True), + Column('data', String(10)) ) @classmethod @@ -684,6 +685,36 @@ class PolymorphicAttributeManagementTest(fixtures.MappedTest): sess.flush ) + def test_not_set_on_upate(self): + C = self.classes.C + + sess = Session() + c1 = C() + sess.add(c1) + sess.commit() + sess.expire(c1) + + c1.data = 'foo' + sess.flush() + + def test_validate_on_upate(self): + C = self.classes.C + + sess = Session() + c1 = C() + sess.add(c1) + sess.commit() + sess.expire(c1) + + c1.class_name = 'b' + assert_raises_message( + sa_exc.SAWarning, + "Flushing object %s with incompatible " + "polymorphic identity 'b'; the object may not " + "refresh and/or load correctly" % instance_str(c1), + sess.flush + ) + class CascadeTest(fixtures.MappedTest): """that cascades on polymorphic relationships continue cascading along the path of the instance's mapper, not |