On Jul 17, 2013, at 10:10 PM, Jonathan Vanasco <[email protected]> wrote:
> > > On Wednesday, July 17, 2013 7:02:10 PM UTC-4, Michael Bayer wrote: > because you can transfer control to some other part of the program that > doesn't know what kind of transaction has started; it only knows it needs to > call commit() or can rollback() if something goes wrong. > > It's a simple re-entrant calling pattern, not unlike how a threading.RLock > works, or nesting of context managers, or anything else that nests. > ... > why do you need the savepoint id ? It seems like you're wanting the core > API, which returns a transactional object specific to that transaction: > http://docs.sqlalchemy.org/en/rel_0_8/core/connections.html#sqlalchemy.engine.Connection.begin_nested > > > 1. so would this work? > > session = SessionFactory() > session.begin() > transaction = session.begin_nested() > transaction.commit() or transaction.rollback() > session.commit() it will, sure ... > even being able to call something a transaction might make this more readable > and alleviate some pain. as-is, everything looks a bit too much like it's > all part of the same outer transaction, which makes auditing code a bit of a > pain. > > 2. my concern is for missing a commit() / rollback() within nested > transactions. > > > passing in that argument to commit/rollback[ `.commit(savepoint)` > > `.rollback(savepoint)` ] would then release / rollback . > > You can't release/commit savepoints out of order, nor can you release/commit > them after the outer transaction has been committed or rolled back. There is > only one order in which operations can proceed. So the current API is the > simplest in that it makes sure you do things this way. > > I wouldn't want to do any of those things, and i'd expect an error thrown if > a savepoint is gone.. > > i guess it's just very confusing going from sql where you have named > savepoints and can explicitly roll back somewhere; and i've got a > > if i have [ transaction , savepointA, savepointB , savepointC , savepointD ] > , it's nice to be able to say "roll back to savepoint B". this is how savepoints should be used: with session.begin_nested(): # do work that is, use context managers, keep things clean, and you never have to deal with a commit(). -- 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 [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/sqlalchemy. For more options, visit https://groups.google.com/groups/opt_out.
