You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by GitBox <gi...@apache.org> on 2022/07/28 19:06:10 UTC

[GitHub] [superset] betodealmeida commented on a diff in pull request #20862: fix: overwrite update override columns on PUT /dataset

betodealmeida commented on code in PR #20862:
URL: https://github.com/apache/superset/pull/20862#discussion_r932580741


##########
tests/integration_tests/datasets/api_tests.py:
##########
@@ -777,6 +777,35 @@ def test_update_dataset_item_w_override_columns(self):
         db.session.delete(dataset)
         db.session.commit()
 
+    def test_update_dataset_item_w_override_columns_same_columns(self):
+        """
+        Dataset API: Test update dataset with override columns
+        """
+        if backend() == "sqlite":
+            return
+
+        # Add default dataset
+        main_db = get_main_database()
+        dataset = self.insert_dataset("flights", [self.get_user("admin").id], main_db)
+
+        self.login(username="admin")
+        dataset_data = {
+            "sql": "SELECT * from flights ",
+            "columns": [
+                {"column_name": "YEAR", "type": "INT", "is_dttm": False},
+                {"column_name": "MONTH", "type": "INT", "is_dttm": False},
+                {"column_name": "DAY", "type": "INT", "is_dttm": False},
+            ],
+        }
+        uri = f"api/v1/dataset/{dataset.id}?override_columns=true"
+        rv = self.put_assert_metric(uri, dataset_data, "put")
+        assert rv.status_code == 200
+
+        columns = db.session.query(TableColumn).filter_by(table_id=dataset.id).all()
+        assert len(columns) == 3

Review Comment:
   Can you add an assert that the number of columns was not 3 before the update? (ie, in line ~790) Otherwise we don't know if the update actually did anything.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org