refactor: replace Engine.execute() with Connection.execute() (#41917)

This commit is contained in:
Hans Yu
2026-07-13 18:40:33 +02:00
committed by GitHub
parent 8f75f1a353
commit 68ebc22e1e
32 changed files with 342 additions and 266 deletions

View File

@@ -922,9 +922,15 @@ class TestDatasetApi(SupersetTestCase):
example_db = get_example_database()
with example_db.get_sqla_engine() as engine:
engine.execute(
text(f"CREATE TABLE {CTAS_SCHEMA_NAME}.birth_names AS SELECT 2 as two")
)
with engine.begin() as conn:
conn.execute(
text(
f"""
CREATE TABLE {CTAS_SCHEMA_NAME}.birth_names AS
SELECT 2 as two
"""
)
)
self.login(ADMIN_USERNAME)
table_data = {
@@ -943,7 +949,8 @@ class TestDatasetApi(SupersetTestCase):
rv = self.client.delete(uri)
assert rv.status_code == 200
with example_db.get_sqla_engine() as engine:
engine.execute(text(f"DROP TABLE {CTAS_SCHEMA_NAME}.birth_names"))
with engine.begin() as conn:
conn.execute(text(f"DROP TABLE {CTAS_SCHEMA_NAME}.birth_names"))
def test_create_dataset_validate_database(self):
"""
@@ -3003,10 +3010,11 @@ class TestDatasetApi(SupersetTestCase):
examples_db = get_example_database()
with examples_db.get_sqla_engine() as engine:
engine.execute(text("DROP TABLE IF EXISTS test_create_sqla_table_api"))
engine.execute(
text("CREATE TABLE test_create_sqla_table_api AS SELECT 2 as col")
)
with engine.begin() as conn:
conn.execute(text("DROP TABLE IF EXISTS test_create_sqla_table_api"))
conn.execute(
text("CREATE TABLE test_create_sqla_table_api AS SELECT 2 as col")
)
rv = self.client.post(
"api/v1/dataset/get_or_create/",
@@ -3030,7 +3038,8 @@ class TestDatasetApi(SupersetTestCase):
self.items_to_delete = [table]
with examples_db.get_sqla_engine() as engine:
engine.execute(text("DROP TABLE test_create_sqla_table_api"))
with engine.begin() as conn:
conn.execute(text("DROP TABLE test_create_sqla_table_api"))
def test_get_or_create_dataset_disambiguates_by_schema(self):
"""