On 5/31/2010 9:55 AM, Michael Bayer wrote:
On May 31, 2010, at 8:24 AM, Kent Bower wrote:
Although sqla doesn't allow the user to specify the savepoint name, the same
could be accomplished given if support for the following were implemented:
Let me ask:
sp_a=begin_nested()
...
...
sp_b=begin_nested()
...
...
sp_c=begin_nested()
...
... #realize I need to go back to sp_a...
sp_a.rollback()
My understanding from the docs, is this is no good currently. I need to first
do commit(), commit() and then rollback() or three rollback()s, correct?
Again, I'm not requesting an enhancement, but would make the point that it
would be more *intuitive* for sqla to figure that out for you, so you could
arbitrarily say sp_a.rollback() and it knows to release or rollback all the
nested transactions living under sp_a.
that's how the engine-level API works - you get at a Transaction object that
you can roll back anywhere in the chain (its up to you to know that the other
Transaction objects in the middle are no longer valid). In the ORM we wanted
to keep things more simplistic. I would note that begin() and begin_nested()
do return the SessionTransaction object though, which does itself include
commit() and rollback() methods. You might want to try the above pattern with
it, as it might accomplish this already ( I didn't write the SessionTransaction
accounting logic).
Ok, good news, that is already taken care of properly, as you
suspected. Both the database rollback to the correct savepoint is
issued and also the session data contains the correct data from before sp_a.
This statement in the docs is what lead me to believe this is not
implemented:
"For each begin_nested() call, a corresponding rollback() or commit()
must be issued." (http://www.sqlalchemy.org/docs/session.html)
That is misleading, I guess, maybe there is a better way to state that
requirement? (I didn't need to issue a rollback or commit() for each
begin_nested(), I am allowed to skip back to a previous one, very nice!)
Thanks
--
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To post to this group, send email to sqlalch...@googlegroups.com.
To unsubscribe from this group, send email to
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/sqlalchemy?hl=en.