* Michael Bayer <mike...@zzzcomputing.com> wrote: > On Jan 31, 2014, at 9:27 AM, Wolfgang Schnerring <w...@gocept.com> wrote: > > savepoint = session.begin_nested() > > session.delete(stuff) > > session.begin_nested() > > # Now, if I don't call session.expire_all() here, stuff won't be perceived > > as gone > > perform_checks_while_pretending_that_stuff_is_gone() > > savepoint.rollback() > > # And if I don't call session.expire_all() here, stuff won't be perceived > > back > > the rollback of a savepoint expires all of those objects which were modified > within the scope of the savepoint. I’m not sure what an expiration at the > beginning of begin_nested() would accomplish (other than forcing everything > to re-load), though a flush() is emitted at that stage, so that if and when a > rollback() does happen we can safely expire back knowing that all state has > been flushed.
I've gathered from the documentation that begin_nested() will issue a flush(). But as far as I understand it, flush() (any flush) will not update the state of collection properties (at least that's what it says in the docs ;), and that matches my observations, too). Thus, if I don't call expire_all(), parent objects still think their children (called ``stuff`` in the example above) exist even though they were deleted. (And likewise after the rollback the parents still think their children are deleted.) I guess I didn't make it clear enough that I'm talking mainly about this collections issue. Sorry about that; let me try again: I feel it would be much more convenient if the state achieved by a savepoint was reflected by collection properties (basically like a real commit), but I don't know whether a) that fits sqlalchemy's usage concept and b) there are adverse performance implications. Does that make more sense? If not I guess I should work up a concrete code example. Thanks again, Wolfgang -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To unsubscribe from this group and stop receiving emails from it, send an email to sqlalchemy+unsubscr...@googlegroups.com. To post to this group, send email to sqlalchemy@googlegroups.com. Visit this group at http://groups.google.com/group/sqlalchemy. For more options, visit https://groups.google.com/groups/opt_out.