mirror of https://github.com/encode/starlette.git
Default rollback_on_shutdown to false in DatabaseMiddleware (#357)
This commit is contained in:
parent
d3a0a723a7
commit
678589b2de
|
@ -155,7 +155,8 @@ if TESTING:
|
||||||
DATABASE_URL = DATABASE_URL.replace(database='test_' + DATABASE_URL.database)
|
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 = Starlette()
|
||||||
app.add_middleware(
|
app.add_middleware(
|
||||||
DatabaseMiddleware,
|
DatabaseMiddleware,
|
||||||
|
|
|
@ -16,7 +16,7 @@ class DatabaseMiddleware:
|
||||||
self,
|
self,
|
||||||
app: ASGIApp,
|
app: ASGIApp,
|
||||||
database_url: typing.Union[str, DatabaseURL],
|
database_url: typing.Union[str, DatabaseURL],
|
||||||
rollback_on_shutdown: bool,
|
rollback_on_shutdown: bool = False,
|
||||||
) -> None:
|
) -> None:
|
||||||
self.app = app
|
self.app = app
|
||||||
self.backend = self.get_backend(database_url)
|
self.backend = self.get_backend(database_url)
|
||||||
|
|
Loading…
Reference in New Issue