Skip to content

Commit

Permalink
feat: export/import allow_dml flag (#22806)
Browse files Browse the repository at this point in the history
  • Loading branch information
betodealmeida committed Jan 25, 2023
1 parent 3898368 commit 6f0fed7
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 0 deletions.
1 change: 1 addition & 0 deletions superset/databases/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions superset/models/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ class Database(
"allow_run_async",
"allow_ctas",
"allow_cvas",
"allow_dml",
"allow_file_upload",
"extra",
]
Expand Down
4 changes: 4 additions & 0 deletions tests/integration_tests/databases/commands_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down
1 change: 1 addition & 0 deletions tests/integration_tests/fixtures/importexport.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
10 changes: 10 additions & 0 deletions tests/unit_tests/databases/commands/importers/v1/import_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
"""
Expand Down
1 change: 1 addition & 0 deletions tests/unit_tests/datasets/commands/export_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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: {{}}
Expand Down

0 comments on commit 6f0fed7

Please sign in to comment.