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 2020/09/24 11:44:36 UTC

[GitHub] [incubator-superset] dpgaspar commented on a change in pull request #11019: fix(api): unable to delete virtual dataset, wrong permission name

dpgaspar commented on a change in pull request #11019:
URL: https://github.com/apache/incubator-superset/pull/11019#discussion_r494247542



##########
File path: superset/datasets/commands/delete.py
##########
@@ -46,27 +46,29 @@ def __init__(self, user: User, model_id: int):
     def run(self) -> Model:
         self.validate()
         try:
+            dataset = DatasetDAO.delete(self._model, commit=False)
+
             view_menu = (
                 security_manager.find_view_menu(self._model.get_perm())
                 if self._model
                 else None
             )
-            if not view_menu:
-                logger.error(
-                    "Could not find the data access permission for the dataset"
+            if view_menu:
+                permission_views = (
+                    db.session.query(security_manager.permissionview_model)
+                        .filter_by(view_menu=view_menu)
+                        .all()
                 )
-                raise DatasetDeleteFailedError()
-            permission_views = (
-                db.session.query(security_manager.permissionview_model)
-                .filter_by(view_menu=view_menu)
-                .all()
-            )
-            dataset = DatasetDAO.delete(self._model, commit=False)
 
-            for permission_view in permission_views:
-                db.session.delete(permission_view)
-            if view_menu:
-                db.session.delete(view_menu)
+                for permission_view in permission_views:
+                    db.session.delete(permission_view)
+                if view_menu:
+                    db.session.delete(view_menu)
+            else:
+                if not view_menu:
+                    logger.error(
+                        "Could not find the data access permission for the dataset"
+                    )

Review comment:
       If dataset a permission does not exist, log the error and delete anyway 




----------------------------------------------------------------
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.

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