From 505719a50aec99f4b77f65d17cf530e08ef108b2 Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Thu, 28 Mar 2024 17:59:24 -0400 Subject: [PATCH] db: turn off autocommit after testing using an assert for DML without a transaction, we can now turn autocommit off. enginefacade should be used completely now Change-Id: I2ee07c7e41ea43c2ab24a4a095550dd0b5fe47dd --- manila/db/sqlalchemy/api.py | 5 ++--- manila/db/sqlalchemy/query.py | 3 +-- manila/test.py | 7 ------- 3 files changed, 3 insertions(+), 12 deletions(-) diff --git a/manila/db/sqlalchemy/api.py b/manila/db/sqlalchemy/api.py index 57e5a8fc9a..335e072f0f 100644 --- a/manila/db/sqlalchemy/api.py +++ b/manila/db/sqlalchemy/api.py @@ -73,11 +73,10 @@ _DEFAULT_SQL_CONNECTION = 'sqlite://' db_options.set_defaults(cfg.CONF, connection=_DEFAULT_SQL_CONNECTION) + context_manager = enginefacade.transaction_context() -# FIXME(stephenfin): we need to remove reliance on autocommit semantics ASAP -# since it's not compatible with SQLAlchemy 2.0 -context_manager.configure(__autocommit=True) +context_manager.configure() def get_engine(): diff --git a/manila/db/sqlalchemy/query.py b/manila/db/sqlalchemy/query.py index 831774d74f..df18fcbe46 100644 --- a/manila/db/sqlalchemy/query.py +++ b/manila/db/sqlalchemy/query.py @@ -28,11 +28,10 @@ class Query(orm.Query): return super(Query, self).soft_delete(synchronize_session) -def get_maker(engine, autocommit=True, expire_on_commit=False): +def get_maker(engine, expire_on_commit=False): """Return a SQLAlchemy sessionmaker using the given engine.""" return sqlalchemy.orm.sessionmaker(bind=engine, class_=orm.Session, - autocommit=autocommit, expire_on_commit=expire_on_commit, query_cls=Query) diff --git a/manila/test.py b/manila/test.py index f1f7fa5651..b714fa9c5d 100644 --- a/manila/test.py +++ b/manila/test.py @@ -186,13 +186,6 @@ class WarningsFixture(fixtures.Fixture): category=sqla_exc.SADeprecationWarning, ) - warnings.filterwarnings( - 'ignore', - module='manila', - message='The current statement is being autocommitted ', - category=sqla_exc.SADeprecationWarning, - ) - warnings.filterwarnings( 'ignore', module='manila',