From 5df23873cf0831822792ec1b56a1b517e2d53c41 Mon Sep 17 00:00:00 2001 From: "Michael S. Molina" Date: Thu, 29 Jun 2023 10:03:03 -0300 Subject: [PATCH 1/2] fix: Deque muteted during iteration --- superset/utils/core.py | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/superset/utils/core.py b/superset/utils/core.py index 226daad45e0c7..ca3b9ae7b7ca6 100644 --- a/superset/utils/core.py +++ b/superset/utils/core.py @@ -850,23 +850,23 @@ def ping_connection(connection: Connection, branch: bool) -> None: # restore 'close with result' connection.should_close_with_result = save_should_close_with_result - if some_engine.dialect.name == "sqlite": - - @event.listens_for(some_engine, "connect") - def set_sqlite_pragma( # pylint: disable=unused-argument - connection: sqlite3.Connection, - *args: Any, - ) -> None: - r""" - Enable foreign key support for SQLite. - - :param connection: The SQLite connection - :param \*args: Additional positional arguments - :see: https://docs.sqlalchemy.org/en/latest/dialects/sqlite.html - """ - - with closing(connection.cursor()) as cursor: - cursor.execute("PRAGMA foreign_keys=ON") + if some_engine.dialect.name == "sqlite": + + @event.listens_for(some_engine, "connect") + def set_sqlite_pragma( # pylint: disable=unused-argument + connection: sqlite3.Connection, + *args: Any, + ) -> None: + r""" + Enable foreign key support for SQLite. + + :param connection: The SQLite connection + :param \*args: Additional positional arguments + :see: https://docs.sqlalchemy.org/en/latest/dialects/sqlite.html + """ + + with closing(connection.cursor()) as cursor: + cursor.execute("PRAGMA foreign_keys=ON") def send_email_smtp( # pylint: disable=invalid-name,too-many-arguments,too-many-locals From c641a735e96513cb0a71a8f0fa7a6582021140be Mon Sep 17 00:00:00 2001 From: "Michael S. Molina" Date: Thu, 29 Jun 2023 10:42:51 -0300 Subject: [PATCH 2/2] Fixes test --- tests/unit_tests/databases/ssh_tunnel/dao_tests.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/unit_tests/databases/ssh_tunnel/dao_tests.py b/tests/unit_tests/databases/ssh_tunnel/dao_tests.py index af0b1ac001d2e..4dfbc5fcd72c0 100644 --- a/tests/unit_tests/databases/ssh_tunnel/dao_tests.py +++ b/tests/unit_tests/databases/ssh_tunnel/dao_tests.py @@ -35,7 +35,7 @@ def test_create_ssh_tunnel(): "password": "bar", } - result = SSHTunnelDAO.create(properties) + result = SSHTunnelDAO.create(properties, commit=False) assert result is not None assert isinstance(result, SSHTunnel)