-
Notifications
You must be signed in to change notification settings - Fork 2
Open
Description
If I try to add another user with the same ID, I get the expected error that comes with trying to violate the unique constraint on ID.
After that however, I get the following error (using both sqlite and postgresql):
site-packages/sqlalchemy/orm/session.py", line 601, in _assert_active raise sa_exc.PendingRollbackError(sqlalchemy.exc.PendingRollbackError: 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: (sqlite3.IntegrityError) UNIQUE constraint failed: user.id
This continues to happen for any transaction until I apply a rollback: session.rollback()
Does something like the following need to be added to the session commits in this library to make sure that this rollback happens automatically?
try:
<use session>
session.commit()
except:
session.rollback()
raise
finally:
session.close() # optional, depends on use case
If not, how can I add code (when using this library) to avoid this happening?
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels