Antti Haapala
unread,Apr 30, 2013, 7:35:05 AM4/30/13Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to sqlalche...@googlegroups.com
postresql 9.x, psycopg 2.5, I think begin_nested is broken:
An example:
obj = User(username='a_duplicate_username_that_causes_unique_violation')
with session.begin_nested():
session.add(obj)
session.flush()
I get an assertion error thrown in session.py:
437 def __exit__(self, type, value, traceback):
--> 438 self._assert_active(prepared_ok=True)
439 if self.session.transaction is None:
440 return
InvalidRequestError: This Session's transaction has been rolled back due to a previous exception during flush. To begin a new transaction with this Session, first issue Session.rollback(). Original exception was: (IntegrityError) duplicate key value violates unique constraint
Is there something changed here? I think the assertion should also have rollback_ok=True? (as the following code first tries commit, and then if all else fails, as it would fail here, rollback) or am I going to cause even more problems with that change?
Thanks in advance