betodealmeida commented on a change in pull request #4651: [explore] proper 
filtering of NULLs and ''
URL: 
https://github.com/apache/incubator-superset/pull/4651#discussion_r181228007
 
 

 ##########
 File path: superset/connectors/base/models.py
 ##########
 @@ -185,6 +186,34 @@ def data(self):
             'verbose_map': verbose_map,
         }
 
+    @staticmethod
+    def filter_values_handler(
+            values, target_column_is_numeric=False, is_list_target=False):
+        def handle_single_value(v):
+            # backward compatibility with previous <select> components
+            if isinstance(v, basestring):
+                v = v.strip().strip("'").strip('"')
+                if target_column_is_numeric:
+                    # For backwards compatibility and edge cases
+                    # where a column data type might have changed
+                    v = utils.string_to_num(v)
+            if v == '<NULL>':
+                return None
+            elif v == '<empty string>':
+                return ''
+            return v
+        if isinstance(values, (list, tuple)):
+            values = [handle_single_value(v) for v in values]
+        values = handle_single_value(values)
+        if is_list_target and not isinstance(values, (tuple, list)):
+            values = [values]
 
 Review comment:
   What if `is_list_target` is true but `values` is a tuple? In this case it 
would return a tuple, is that ok?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to