superset-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From maximebeauche...@apache.org
Subject [incubator-superset] branch master updated: [Bugfix] Issues with merge_extra_filters (#4042) (#4091)
Date Thu, 21 Dec 2017 00:22:53 GMT
This is an automated email from the ASF dual-hosted git repository.

maximebeauchemin pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-superset.git


The following commit(s) were added to refs/heads/master by this push:
     new b4909f2  [Bugfix] Issues with merge_extra_filters (#4042) (#4091)
b4909f2 is described below

commit b4909f2d030efc57612a63f31f66f0f0f7a61cf9
Author: Nicolas Bonnotte <nbonnotte@users.noreply.github.com>
AuthorDate: Thu Dec 21 01:22:43 2017 +0100

    [Bugfix] Issues with merge_extra_filters (#4042) (#4091)
---
 superset/utils.py    |  3 ++-
 tests/utils_tests.py | 17 +++++++++++++++++
 2 files changed, 19 insertions(+), 1 deletion(-)

diff --git a/superset/utils.py b/superset/utils.py
index afe2f41..c64e8cf 100644
--- a/superset/utils.py
+++ b/superset/utils.py
@@ -735,7 +735,8 @@ def merge_extra_filters(form_data):
             return f['col'] + '__' + f['op']
         existing_filters = {}
         for existing in form_data['filters']:
-            existing_filters[get_filter_key(existing)] = existing['val']
+            if existing['col'] is not None:
+                existing_filters[get_filter_key(existing)] = existing['val']
         for filtr in form_data['extra_filters']:
             # Pull out time filters/options and merge into form data
             if date_options.get(filtr['col']):
diff --git a/tests/utils_tests.py b/tests/utils_tests.py
index 46d4766..04a70b8 100644
--- a/tests/utils_tests.py
+++ b/tests/utils_tests.py
@@ -119,6 +119,23 @@ class UtilsTestCase(unittest.TestCase):
         merge_extra_filters(form_data)
         self.assertEquals(form_data, expected)
 
+    def test_merge_extra_filters_ignores_nones(self):
+        form_data = {
+            'filters': [
+                {'col': None, 'op': 'in', 'val': ''},
+            ],
+            'extra_filters': [
+                {'col': 'B', 'op': '==', 'val': []},
+            ],
+        }
+        expected = {
+            'filters': [
+                {'col': None, 'op': 'in', 'val': ''},
+            ],
+        }
+        merge_extra_filters(form_data)
+        self.assertEquals(form_data, expected)
+
     def test_merge_extra_filters_ignores_equal_filters(self):
         form_data = {
             'extra_filters': [

-- 
To stop receiving notification emails like this one, please contact
['"commits@superset.apache.org" <commits@superset.apache.org>'].

Mime
View raw message