You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@superset.apache.org by GitBox <gi...@apache.org> on 2017/12/21 00:22:47 UTC
[GitHub] mistercrunch closed pull request #4091: Fix merge_extra_filters
mistercrunch closed pull request #4091: Fix merge_extra_filters
URL: https://github.com/apache/incubator-superset/pull/4091
This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:
As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):
diff --git a/superset/utils.py b/superset/utils.py
index afe2f419ad..c64e8cf4ee 100644
--- a/superset/utils.py
+++ b/superset/utils.py
@@ -735,7 +735,8 @@ def get_filter_key(f):
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 46d476632b..04a70b8f60 100644
--- a/tests/utils_tests.py
+++ b/tests/utils_tests.py
@@ -119,6 +119,23 @@ def test_merge_extra_filters_ignores_empty_filters(self):
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': [
----------------------------------------------------------------
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:
users@infra.apache.org
With regards,
Apache Git Services