mirror of
https://github.com/apache/superset.git
synced 2026-07-18 20:55:47 +00:00
refactor: replace Engine.execute() with Connection.execute() (#41917)
This commit is contained in:
@@ -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):
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user