cccs-jc commented on a change in pull request #14765:
URL: https://github.com/apache/superset/pull/14765#discussion_r642109477



##########
File path: superset/views/utils.py
##########
@@ -196,6 +199,26 @@ def get_form_data(  # pylint: disable=too-many-locals
     return form_data, slc
 
 
+def add_sqllab_custom_filters(form_data: Dict[Any, Any]) -> Any:
+    """
+    SQLLab can include a "filters" attribute in the templateParams.
+    The filters attribute is a list of filters to include in the
+    request. Useful for testing templates in SQLLab.
+    """
+    try:
+        data = json.loads(request.data)
+        if isinstance(data, dict):
+            params_str = data.get("templateParams")
+            if isinstance(params_str, str):
+                params = json.loads(params_str)
+                if isinstance(params, dict):
+                    filters = params.get("filters")
+                    if filters:
+                        form_data.update({"filters": filters})
+    except (TypeError, json.JSONDecodeError):
+        data = {}

Review comment:
       I now removed `filters` from the templateParams before saving the 
dataset. I think this makes sense since it's really only used to test the 
templates.
   
   With regards to collisions with `filter_values` this does not occur. From a 
templateParams if a user specifies `filter_values` it's not seen by the 
template. The `filter_values` remains active.




-- 
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:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to