]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
added a test for #1349
authorMike Bayer <mike_mp@zzzcomputing.com>
Tue, 3 Nov 2009 04:30:18 +0000 (04:30 +0000)
committerMike Bayer <mike_mp@zzzcomputing.com>
Tue, 3 Nov 2009 04:30:18 +0000 (04:30 +0000)
test/orm/test_cascade.py

index c523fb5f0134e71d657d972ce65d9c6d76324be0..3b9481dae9e4207c021ad65f008043f9d9c93594 100644 (file)
@@ -742,6 +742,28 @@ class M2MCascadeTest(_base.MappedTest):
         assert b.count().scalar() == 0
         assert a.count().scalar() == 1
 
+    @testing.resolve_artifact_names
+    def test_delete_orphan_dynamic(self):
+        mapper(A, a, properties={
+            # if no backref here, delete-orphan failed until [ticket:427] was
+            # fixed
+            'bs': relation(B, secondary=atob, 
+                    cascade="all, delete-orphan", single_parent=True,lazy="dynamic")
+        })
+        mapper(B, b)
+
+        sess = create_session()
+        b1 = B(data='b1')
+        a1 = A(data='a1', bs=[b1])
+        sess.add(a1)
+        sess.flush()
+
+        a1.bs.remove(b1)
+        sess.flush()
+        assert atob.count().scalar() ==0
+        assert b.count().scalar() == 0
+        assert a.count().scalar() == 1
+
     @testing.resolve_artifact_names
     def test_delete_orphan_cascades(self):
         mapper(A, a, properties={