Skip to content

Commit

Permalink
Fix bug where lists in queries cannot contain multiple types (#8032)
Browse files Browse the repository at this point in the history
* use set instead of sorted to check equality of lists

* run black
  • Loading branch information
serenajiang authored and villebro committed Aug 13, 2019
1 parent 075b5a5 commit 17f0740
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
4 changes: 1 addition & 3 deletions superset/utils/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -907,9 +907,7 @@ def get_filter_key(f):
if isinstance(existing_filters[filter_key], list):
# Add filters for unequal lists
# order doesn't matter
if sorted(existing_filters[filter_key]) != sorted(
filtr["val"]
):
if set(existing_filters[filter_key]) != set(filtr["val"]):
form_data["adhoc_filters"].append(to_adhoc(filtr))
else:
form_data["adhoc_filters"].append(to_adhoc(filtr))
Expand Down
15 changes: 15 additions & 0 deletions tests/utils_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,7 @@ def test_merge_extra_filters_ignores_equal_filters(self):
"extra_filters": [
{"col": "a", "op": "in", "val": "someval"},
{"col": "B", "op": "==", "val": ["c1", "c2"]},
{"col": "c", "op": "in", "val": ["c1", 1, None]},
],
"adhoc_filters": [
{
Expand All @@ -317,6 +318,13 @@ def test_merge_extra_filters_ignores_equal_filters(self):
"operator": "==",
"subject": "B",
},
{
"clause": "WHERE",
"comparator": ["c1", 1, None],
"expressionType": "SIMPLE",
"operator": "in",
"subject": "c",
},
],
}
expected = {
Expand All @@ -335,6 +343,13 @@ def test_merge_extra_filters_ignores_equal_filters(self):
"operator": "==",
"subject": "B",
},
{
"clause": "WHERE",
"comparator": ["c1", 1, None],
"expressionType": "SIMPLE",
"operator": "in",
"subject": "c",
},
]
}
merge_extra_filters(form_data)
Expand Down

0 comments on commit 17f0740

Please sign in to comment.