From 4d882edc30fc399187d98a9f3bea26f334561c74 Mon Sep 17 00:00:00 2001 From: Stephen Finucane Date: Tue, 26 Sep 2023 15:06:24 +0100 Subject: [PATCH] db: Use raw connection to enable foreign keys SQLAlchemy 2.0 wraps mostly everything in transactions, which limits our ability to do this easily on a non-global basis. Use the raw connection [1] instead. [1] https://docs.python.org/3/library/sqlite3.html#sqlite3.Connection.execute Signed-off-by: Stephen Finucane Change-Id: Ic2bbf59550e965769c6b64f3e5eeec9783c6b290 --- heat/tests/utils.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/heat/tests/utils.py b/heat/tests/utils.py index d1f9e5daf0..b261020b68 100644 --- a/heat/tests/utils.py +++ b/heat/tests/utils.py @@ -231,12 +231,12 @@ class ForeignKeyConstraintFixture(fixtures.Fixture): if self.engine.name == 'sqlite': with self.engine.connect() as conn: - conn.exec_driver_sql("PRAGMA foreign_keys = ON") + conn.connection.execute("PRAGMA foreign_keys = ON") def disable_fks(): with self.engine.connect() as conn: conn.connection.rollback() - conn.exec_driver_sql("PRAGMA foreign_keys=OFF") + conn.connection.execute("PRAGMA foreign_keys = OFF") self.addCleanup(disable_fks)