You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by "betodealmeida (via GitHub)" <gi...@apache.org> on 2023/06/02 22:35:04 UTC

[GitHub] [superset] betodealmeida commented on a diff in pull request #24279: fix(migrations): Fixing cross filter migration

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


##########
superset/migrations/versions/2023-05-11_12-41_4ea966691069_cross_filter_global_scoping.py:
##########
@@ -91,20 +94,24 @@ def downgrade():
                 chart_id = config.get("id")
                 if chart_id is None:
                     continue
-                scope = config.get("crossFilters", {}).get("scope", {})
+                scope = config.get("crossFilters", {}).get("scope", "")
                 new_chart_configuration[chart_id] = copy.deepcopy(config)
-                if scope == "global":
+                if scope.lower() == "global":
                     new_chart_configuration[chart_id]["crossFilters"]["scope"] = {
                         "rootPath": ["ROOT_ID"],
                         "excluded": [chart_id],
                     }
 
             json_metadata["chart_configuration"] = new_chart_configuration
-            del json_metadata["global_chart_configuration"]
+
+            if "global_chart_configuration" in json_metadata:
+                del json_metadata["global_chart_configuration"]
+

Review Comment:
   `.pop()` fails if the key doesn't exist:
   
   ```python
   >>> {}.pop(1)
   Traceback (most recent call last):
     File "<stdin>", line 1, in <module>
   KeyError: 1
   ```



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