fix: import dataset/dashboard empty keys (#13979)
(cherry picked from commit 3b11654c5aaa7a32d75ee1431929b667fe67ff5d)
diff --git a/superset/dashboards/commands/importers/v1/utils.py b/superset/dashboards/commands/importers/v1/utils.py
index 9802767..09d786c 100644
--- a/superset/dashboards/commands/importers/v1/utils.py
+++ b/superset/dashboards/commands/importers/v1/utils.py
@@ -115,7 +115,7 @@
# TODO (betodealmeida): move this logic to import_from_dict
config = config.copy()
for key, new_name in JSON_KEYS.items():
- if config.get(key):
+ if config.get(key) is not None:
value = config.pop(key)
try:
config[new_name] = json.dumps(value)
diff --git a/superset/datasets/commands/importers/v1/utils.py b/superset/datasets/commands/importers/v1/utils.py
index 73c0ca5..882faf2 100644
--- a/superset/datasets/commands/importers/v1/utils.py
+++ b/superset/datasets/commands/importers/v1/utils.py
@@ -92,7 +92,7 @@
# TODO (betodealmeida): move this logic to import_from_dict
config = config.copy()
for key in JSON_KEYS:
- if config.get(key):
+ if config.get(key) is not None:
try:
config[key] = json.dumps(config[key])
except TypeError:
diff --git a/tests/datasets/commands_tests.py b/tests/datasets/commands_tests.py
index f72e7f3..84c1089 100644
--- a/tests/datasets/commands_tests.py
+++ b/tests/datasets/commands_tests.py
@@ -312,7 +312,7 @@
assert dataset.schema == ""
assert dataset.sql == ""
assert dataset.params is None
- assert dataset.template_params is None
+ assert dataset.template_params == "{}"
assert dataset.filter_select_enabled
assert dataset.fetch_values_predicate is None
assert dataset.extra is None
diff --git a/tests/fixtures/importexport.py b/tests/fixtures/importexport.py
index e1752fc..c815642 100644
--- a/tests/fixtures/importexport.py
+++ b/tests/fixtures/importexport.py
@@ -368,7 +368,7 @@
"schema": "",
"sql": "",
"params": None,
- "template_params": None,
+ "template_params": {},
"filter_select_enabled": True,
"fetch_values_predicate": None,
"extra": None,