mfreeborn / fastapi-sqlalchemy

Adds simple SQLAlchemy support to FastAPI
MIT License
619 stars 38 forks source link

Allow session rollbacks on HTTPExceptions #43

Open mghh opened 1 year ago

mghh commented 1 year ago

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

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).