This is an automated email from the ASF dual-hosted git repository. hugh pushed a commit to branch hugh/ds-overwrite-better in repository https://gitbox.apache.org/repos/asf/superset.git
commit 350f4632d004c43b2f2b21ec15c252e7d1906c4b Author: hughhhh <[email protected]> AuthorDate: Fri Oct 1 13:53:46 2021 -0700 check if owners are actually being updated --- superset/datasets/commands/update.py | 5 +++-- superset/datasets/dao.py | 1 - tests/integration_tests/datasets/api_tests.py | 19 +++++++++++++++++++ 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/superset/datasets/commands/update.py b/superset/datasets/commands/update.py index 9ae2bd4..b06f632 100644 --- a/superset/datasets/commands/update.py +++ b/superset/datasets/commands/update.py @@ -98,8 +98,9 @@ class UpdateDatasetCommand(UpdateMixin, BaseCommand): exceptions.append(DatabaseChangeValidationError()) # Validate/Populate owner try: - owners = self.populate_owners(self._actor, owner_ids) - self._properties["owners"] = owners + if owner_ids: + owners = self.populate_owners(self._actor, owner_ids) + self._properties["owners"] = owners except ValidationError as ex: exceptions.append(ex) diff --git a/superset/datasets/dao.py b/superset/datasets/dao.py index b58622b..646d274 100644 --- a/superset/datasets/dao.py +++ b/superset/datasets/dao.py @@ -159,7 +159,6 @@ class DatasetDAO(BaseDAO): # pylint: disable=too-many-public-methods properties["metrics"] = cls.update_metrics( model, properties.get("metrics", []), commit=commit ) - return super().update(model, properties, commit=False) @classmethod diff --git a/tests/integration_tests/datasets/api_tests.py b/tests/integration_tests/datasets/api_tests.py index e2babb8..3d6f901 100644 --- a/tests/integration_tests/datasets/api_tests.py +++ b/tests/integration_tests/datasets/api_tests.py @@ -657,6 +657,25 @@ class TestDatasetApi(SupersetTestCase): db.session.delete(dataset) db.session.commit() + def test_update_dataset_owners_kept(self): + """ + Dataset API: Test update dataset does not clear owners + """ + dataset = self.insert_default_dataset() + print(dataset) + + self.login(username="admin") + dataset_data = {"description": "Arash's metrics for a successful Series C"} + uri = f"api/v1/dataset/{dataset.id}" + rv = self.put_assert_metric(uri, dataset_data, "put") + assert rv.status_code == 200 + + model = db.session.query(SqlaTable).get(dataset.id) + assert model.owners == dataset.owners + + db.session.delete(dataset) + db.session.commit() + def test_update_dataset_create_column(self): """ Dataset API: Test update dataset create column
