From: Mike Bayer Date: Thu, 1 Apr 2010 20:23:02 +0000 (-0400) Subject: the delete parent o2m test X-Git-Tag: rel_0_6_0~72 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=bffdb4db3596aeb28bc2072672a0c6b388c0a877;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git the delete parent o2m test --- diff --git a/test/orm/test_unitofworkv2.py b/test/orm/test_unitofworkv2.py index 4ccc3df689..29de77c817 100644 --- a/test/orm/test_unitofworkv2.py +++ b/test/orm/test_unitofworkv2.py @@ -250,4 +250,27 @@ class SingleCycleTest(UOWTest): ), CompiledSQL("DELETE FROM nodes WHERE nodes.id = :id", {'id':1}) ) + + def test_one_to_many_delete_parent(self): + mapper(Node, nodes, properties={ + 'children':relationship(Node) + }) + sess = create_session() + + n2, n3 = Node(data='n2', children=[]), Node(data='n3', children=[]) + n1 = Node(data='n1', children=[n2, n3]) + + sess.add(n1) + sess.flush() + + sess.delete(n1) + self.assert_sql_execution( + testing.db, + sess.flush, + AllOf( + CompiledSQL("UPDATE nodes SET parent_id=:parent_id WHERE nodes.id = :nodes_id", {'nodes_id':3, 'parent_id':None}), + CompiledSQL("UPDATE nodes SET parent_id=:parent_id WHERE nodes.id = :nodes_id", {'nodes_id':2, 'parent_id':None}), + ), + CompiledSQL("DELETE FROM nodes WHERE nodes.id = :id", {'id':1}) + )