From 2e1e0f6dc4d1dabf839f2a181e97feeceb20e67f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9gis=20Behmo?= Date: Tue, 25 May 2021 14:53:48 +0200 Subject: [PATCH] fix: actually write changes on "superset import-datasources" When running the following command: superset import-datasources --path=datasource.json the data stored in "datasources.json" may either be dict or a list. In the case of a dataset exported from a live superset instance, it is a list. When it is re-imported, the `SqlaTable.import_from_dict` utility method is used. This method does not commit changes to the database, so the imported datasets are never saved to the database, causing frustration and sadness. --- superset/commands/dataset/importers/v0.py | 1 + 1 file changed, 1 insertion(+) diff --git a/superset/commands/dataset/importers/v0.py b/superset/commands/dataset/importers/v0.py index 14be54174a9f3..acfe4a2c9160e 100644 --- a/superset/commands/dataset/importers/v0.py +++ b/superset/commands/dataset/importers/v0.py @@ -260,6 +260,7 @@ def run(self) -> None: ) dataset["database_id"] = database.id SqlaTable.import_from_dict(dataset, sync=self.sync) + db.session.commit() def validate(self) -> None: # ensure all files are YAML