Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: auto commit txn on aexit #52

Closed

Conversation

dbluhm
Copy link
Contributor

@dbluhm dbluhm commented Jun 5, 2022

This is an attempt to visualize what #51 would look like. I think it's this simple?

As implemented, instead of an effective "rollback by default", it will rollback if the transaction exits with an exception but otherwise commit by default. The user may still choose to manually call rollback before the context is exited.

Signed-off-by: Daniel Bluhm <dbluhm@pm.me>
@dbluhm dbluhm requested a review from andrewwhitehead June 5, 2022 02:20
await session.rollback()
else:
await session.commit()

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the close() should be in an else block, as commit and rollback both close the session.

@andrewwhitehead
Copy link
Contributor

I think this makes sense, but I should put out another patch release before making this kind of breaking change. Also maybe a log statement when it rolls back due to an exception?

@andrewwhitehead
Copy link
Contributor

Planning to add this (or the equivalent) to 0.3.x shortly.

@andrewwhitehead
Copy link
Contributor

Added support for an autocommit flag in #162

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants