Skip to content

Commit

Permalink
Merge pull request #16 from ValtechMobility/datasource_id_fix
Browse files Browse the repository at this point in the history
added PR to ensure old datasource Ids are not referenced in imported …
  • Loading branch information
philipher29 authored Nov 20, 2023
2 parents f06d481 + 82bd302 commit 2137a0d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
8 changes: 7 additions & 1 deletion superset/dashboards/commands/importers/v1/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,13 @@ def _import(
and config["dataset_uuid"] in dataset_info
):
# update datasource id, type, and name
config.update(dataset_info[config["dataset_uuid"]])
dataset_dict = dataset_info[config["dataset_uuid"]]
config.update(dataset_dict)
# pylint: disable=line-too-long
dataset_uid = f"{dataset_dict['datasource_id']}__{dataset_dict['datasource_type']}"
config["params"].update({"datasource": dataset_uid})
if "query_context" in config:
del config["query_context"]
chart = import_chart(session, config, overwrite=False)
chart_ids[str(chart.uuid)] = chart.id

Expand Down
3 changes: 3 additions & 0 deletions tests/integration_tests/dashboards/commands_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -564,6 +564,9 @@ def test_import_v1_dashboard(self, mock_g):
dataset = chart.table
assert str(dataset.uuid) == dataset_config["uuid"]

assert chart.query_context is None
assert json.loads(chart.params)["datasource"] == dataset.uid

database = dataset.database
assert str(database.uuid) == database_config["uuid"]

Expand Down

0 comments on commit 2137a0d

Please sign in to comment.