On Feb 11, 2014, at 3:44 AM, Wolfgang Schnerring <[email protected]> wrote:
> def test_children_should_be_removed_from_collection_on_savepoint(self): > session = self.sessionmaker() > parent = Parent() > Child(parent=parent) > session.add(parent) > session.commit() > > parent = session.query(Parent).first() > self.assertEqual(1, len(parent.children)) > session.begin_nested() > session.delete(parent.children[0]) > self.assertEqual(0, len(parent.children)) > > > My point is, the last assertion fails, which I find both surprising and > inconvenient. ;) I'd be grateful for any insights you have about this. I’m pretty sure I mentioned this was what it seemed like you were describing. this is the “delete() on an object doesn’t remove it from all collections in which it is contained”. it’s not related to savepoints and you can read about how to work with this behavior here: http://docs.sqlalchemy.org/en/rel_0_9/faq.html#i-m-calling-session-delete-myobject-and-it-isn-t-removed-from-the-parent-collection http://docs.sqlalchemy.org/en/rel_0_9/orm/session.html#session-deleting-from-collections
signature.asc
Description: Message signed with OpenPGP using GPGMail
