diff --git a/docs/database.md b/docs/database.md index 016f3c50..9f37eb70 100644 --- a/docs/database.md +++ b/docs/database.md @@ -155,7 +155,8 @@ if TESTING: DATABASE_URL = DATABASE_URL.replace(database='test_' + DATABASE_URL.database) -# Use 'rollback_on_shutdown' during testing, to ensure we have +# Use 'rollback_on_shutdown' during testing, to ensure we do not persist +# database changes app = Starlette() app.add_middleware( DatabaseMiddleware, diff --git a/starlette/middleware/database.py b/starlette/middleware/database.py index 3c64b42f..006cd558 100644 --- a/starlette/middleware/database.py +++ b/starlette/middleware/database.py @@ -16,7 +16,7 @@ class DatabaseMiddleware: self, app: ASGIApp, database_url: typing.Union[str, DatabaseURL], - rollback_on_shutdown: bool, + rollback_on_shutdown: bool = False, ) -> None: self.app = app self.backend = self.get_backend(database_url)