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_r181227743
 
 

 ##########
 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)
 
 Review comment:
   This is a bit confusing... I'd add the second call to an `else` block 
(unless I'm missing something):
   
   ```python
   if isinstance(values, (list, tuple)):
       values = [handle_single_value(v) for v in values]
   else:
       values = handle_single_value(values)
   ```

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