diff --git a/ironic_inspector/db.py b/ironic_inspector/db.py index ae00081e6..cfa2b1120 100644 --- a/ironic_inspector/db.py +++ b/ironic_inspector/db.py @@ -174,7 +174,9 @@ def _create_context_manager(): _ctx_mgr = enginefacade.transaction_context() # TODO(aarefiev): enable foreign keys for SQLite once all unit # tests with failed constraint will be fixed. - _ctx_mgr.configure(sqlite_fk=False) + # FIXME(dtantsur): we need to remove reliance on autocommit semantics ASAP + # since it's not compatible with SQLAlchemy 2.0 + _ctx_mgr.configure(sqlite_fk=False, __autocommit=True) return _ctx_mgr diff --git a/ironic_inspector/test/unit/test_db.py b/ironic_inspector/test/unit/test_db.py index c7134a6ad..f73ca338c 100644 --- a/ironic_inspector/test/unit/test_db.py +++ b/ironic_inspector/test/unit/test_db.py @@ -53,7 +53,10 @@ class TestDB(test_base.NodeTest): ctx_mgr = db._create_context_manager() - mock_ctx_mgr.configure.assert_called_once_with(sqlite_fk=False) + mock_ctx_mgr.configure.assert_called_once_with( + sqlite_fk=False, + __autocommit=True, + ) self.assertEqual(mock_ctx_mgr, ctx_mgr) @mock.patch.object(db, 'get_context_manager', autospec=True) diff --git a/ironic_inspector/test/unit/test_migrations.py b/ironic_inspector/test/unit/test_migrations.py index 7f101c750..6f8715588 100644 --- a/ironic_inspector/test/unit/test_migrations.py +++ b/ironic_inspector/test/unit/test_migrations.py @@ -56,8 +56,10 @@ def patch_with_engine(engine): autospec=True) as patch_w_sess, \ mock.patch.object(db, 'get_reader_session', autospec=True) as patch_r_sess: + # FIXME(stephenfin): we need to remove reliance on autocommit semantics + # ASAP since it's not compatible with SQLAlchemy 2.0 patch_w_sess.return_value = patch_r_sess.return_value = ( - orm.get_maker(engine)()) + orm.get_maker(engine, autocommit=True)()) yield