You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by be...@apache.org on 2026/04/15 15:10:32 UTC
(superset) branch master updated: fix: `do_ping` takes a connection, not engine (#39013)
This is an automated email from the ASF dual-hosted git repository.
beto pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/superset.git
The following commit(s) were added to refs/heads/master by this push:
new 84f7b4a9731 fix: `do_ping` takes a connection, not engine (#39013)
84f7b4a9731 is described below
commit 84f7b4a973191d6cec687af3b17f6d0a464f38fa
Author: Beto Dealmeida <ro...@dealmeida.net>
AuthorDate: Wed Apr 15 11:10:24 2026 -0400
fix: `do_ping` takes a connection, not engine (#39013)
---
superset/commands/database/utils.py | 3 ++-
tests/unit_tests/commands/databases/utils_test.py | 6 +++---
2 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/superset/commands/database/utils.py b/superset/commands/database/utils.py
index e850a9e89ee..0c25f8173c2 100644
--- a/superset/commands/database/utils.py
+++ b/superset/commands/database/utils.py
@@ -47,7 +47,8 @@ def ping(engine: Engine) -> bool:
except (sqlite3.ProgrammingError, RuntimeError):
# SQLite can't run on a separate thread, so ``utils.timeout`` fails
# RuntimeError catches the equivalent error from duckdb.
- return engine.dialect.do_ping(engine)
+ with closing(engine.raw_connection()) as conn:
+ return engine.dialect.do_ping(conn)
def add_permissions(database: Database) -> None:
diff --git a/tests/unit_tests/commands/databases/utils_test.py b/tests/unit_tests/commands/databases/utils_test.py
index 04512e47f4f..a8fb3a36e54 100644
--- a/tests/unit_tests/commands/databases/utils_test.py
+++ b/tests/unit_tests/commands/databases/utils_test.py
@@ -77,7 +77,7 @@ def test_ping_sqlite_exception(mocker: MockerFixture, mock_engine: MockerFixture
assert result is True
mock_dialect.do_ping.assert_has_calls(
- [mocker.call(mock_connection), mocker.call(mock_engine)]
+ [mocker.call(mock_connection), mocker.call(mock_connection)]
)
@@ -85,7 +85,7 @@ def test_ping_runtime_exception(mocker: MockerFixture, mock_engine: MockerFixtur
"""
Test the ``ping`` method when a RuntimeError is raised.
"""
- mock_engine, _, mock_dialect = mock_engine
+ mock_engine, mock_connection, mock_dialect = mock_engine
mock_timeout = mocker.patch("superset.commands.database.utils.timeout")
mock_timeout.side_effect = RuntimeError("timeout")
mock_dialect.do_ping.return_value = True
@@ -93,7 +93,7 @@ def test_ping_runtime_exception(mocker: MockerFixture, mock_engine: MockerFixtur
result = ping(mock_engine)
assert result is True
- mock_dialect.do_ping.assert_called_once_with(mock_engine)
+ mock_dialect.do_ping.assert_called_once_with(mock_connection)
@pytest.fixture