Skip to content

Allow session rollbacks on HTTPExceptions #43

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

mghh
Copy link

@mghh mghh commented Jan 30, 2023

By default fastapi handles HTTPExceptions and does not raise inside the fastapi-sqlalchemy middleware. We introduce two new parameters to control rollback behaviour:

  • rollback_on_client_error rolls back on 40x http exceptions
  • rollback_on_server_error rolls back on 50x http exceptions

Additional we add support to force rollback if used outside a route in context manager by setting the attribute
force_rollback on the session context (see tests/test_session.py).

By default fastapi handles HTTPExceptions and does
not raise inside the fastapi-sqlalchemy middleware.
We introduce two new parameters to control rollback behaviour:

- rollback_on_client_error rolls back on 40x http exceptions
- rollback_on_server_error rolls back on 50x http exceptions

Additional we add support to force rollback if used outside a
route in context manager by setting the attribute
`force_rollback` on the session context (see tests/test_session.py).
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.

1 participant