According to my tests it is, or at least the end result is savepoint release being emitted before final commit. For this code:


sp = transaction.savepoint()
    ... do something
    session.flush()

sp2 = transaction.savepoint()
    ... do something
    session.flush()
        # Oops, IntegrityError
        sp.rollback()

...

transaction.commit()


The following SQL is emitted:

BEGIN (implicit)
...
SAVEPOINT sa_savepoint_1
...
SAVEPOINT sa_savepoint_2
ROLLBACK TO SAVEPOINT sa_savepoint_2
...
RELEASE SAVEPOINT sa_savepoint_1
COMMIT


The test (resulting with the SQL above) is posted here. You can vary the params at the beginning to try various combinations with or without the Transaction.

https://gist.github.com/1370792






.oO V Oo.


On 11/16/2011 05:07 PM, Michael Merickel wrote:
I will say that after looking at the SQLAlchemy documentation once again, it does say "For each begin_nested() call, a corresponding rollback() or commit() must be issued." and even from looking at the unit tests in zope.sqlalchemy I cannot tell where the required commit() is issued per savepoint. This may be worth investigating regardless of whether your problem is solved. :-)

http://svn.zope.org/zope.sqlalchemy/trunk/src/zope/sqlalchemy/

--
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To post to this group, send email to pylons-discuss@googlegroups.com.
To unsubscribe from this group, send email to 
pylons-discuss+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en.

Reply via email to