diff --git a/superset/databases/schemas.py b/superset/databases/schemas.py index 8ad2ab706fb2f..7f9ea04d7a939 100644 --- a/superset/databases/schemas.py +++ b/superset/databases/schemas.py @@ -683,6 +683,7 @@ def fix_allow_csv_upload( allow_run_async = fields.Boolean() allow_ctas = fields.Boolean() allow_cvas = fields.Boolean() + allow_dml = fields.Boolean(required=False) allow_csv_upload = fields.Boolean() extra = fields.Nested(ImportV1DatabaseExtraSchema) uuid = fields.UUID(required=True) diff --git a/superset/models/core.py b/superset/models/core.py index 403d0f6c18f7a..4186a9a086dd1 100755 --- a/superset/models/core.py +++ b/superset/models/core.py @@ -168,6 +168,7 @@ class Database( "allow_run_async", "allow_ctas", "allow_cvas", + "allow_dml", "allow_file_upload", "extra", ] diff --git a/tests/integration_tests/databases/commands_tests.py b/tests/integration_tests/databases/commands_tests.py index 64c9b260c4ab9..0a9defc3505b8 100644 --- a/tests/integration_tests/databases/commands_tests.py +++ b/tests/integration_tests/databases/commands_tests.py @@ -159,6 +159,7 @@ def test_export_database_command(self, mock_g): "allow_csv_upload": True, "allow_ctas": True, "allow_cvas": True, + "allow_dml": True, "allow_run_async": False, "cache_timeout": None, "database_name": "examples", @@ -362,6 +363,7 @@ def test_export_database_command_key_order(self, mock_g): "allow_run_async", "allow_ctas", "allow_cvas", + "allow_dml", "allow_csv_upload", "extra", "uuid", @@ -405,6 +407,7 @@ def test_import_v1_database(self): assert database.allow_file_upload assert database.allow_ctas assert database.allow_cvas + assert database.allow_dml assert not database.allow_run_async assert database.cache_timeout is None assert database.database_name == "imported_database" @@ -440,6 +443,7 @@ def test_import_v1_database_broken_csv_fields(self): assert database.allow_file_upload assert database.allow_ctas assert database.allow_cvas + assert database.allow_dml assert not database.allow_run_async assert database.cache_timeout is None assert database.database_name == "imported_database" diff --git a/tests/integration_tests/fixtures/importexport.py b/tests/integration_tests/fixtures/importexport.py index 18bec4f17995b..b624f3e63ced6 100644 --- a/tests/integration_tests/fixtures/importexport.py +++ b/tests/integration_tests/fixtures/importexport.py @@ -350,6 +350,7 @@ "allow_csv_upload": True, "allow_ctas": True, "allow_cvas": True, + "allow_dml": True, "allow_run_async": False, "cache_timeout": None, "database_name": "imported_database", diff --git a/tests/unit_tests/databases/commands/importers/v1/import_test.py b/tests/unit_tests/databases/commands/importers/v1/import_test.py index f482e16d8a685..e665bcb505d55 100644 --- a/tests/unit_tests/databases/commands/importers/v1/import_test.py +++ b/tests/unit_tests/databases/commands/importers/v1/import_test.py @@ -41,12 +41,22 @@ def test_import_database(session: Session) -> None: assert database.allow_run_async is False assert database.allow_ctas is True assert database.allow_cvas is True + assert database.allow_dml is True assert database.allow_file_upload is True assert database.extra == "{}" assert database.uuid == "b8a1ccd3-779d-4ab7-8ad8-9ab119d7fe89" assert database.is_managed_externally is False assert database.external_url is None + # ``allow_dml`` was initially not exported; the import should work if the field is + # missing + config = copy.deepcopy(database_config) + del config["allow_dml"] + session.delete(database) + session.flush() + database = import_database(session, config) + assert database.allow_dml is False + def test_import_database_managed_externally(session: Session) -> None: """ diff --git a/tests/unit_tests/datasets/commands/export_test.py b/tests/unit_tests/datasets/commands/export_test.py index aa444b5fd734a..c3ad4f764c4f3 100644 --- a/tests/unit_tests/datasets/commands/export_test.py +++ b/tests/unit_tests/datasets/commands/export_test.py @@ -194,6 +194,7 @@ def test_export(session: Session) -> None: allow_run_async: false allow_ctas: false allow_cvas: false +allow_dml: false allow_file_upload: false extra: metadata_params: {{}}