Skip to content

Commit

Permalink
Allow trailing spaces in simple filter values (#7617)
Browse files Browse the repository at this point in the history
  • Loading branch information
Erik Ritter authored and betodealmeida committed Jun 1, 2019
1 parent 15d0361 commit 722043c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
2 changes: 1 addition & 1 deletion superset/connectors/base/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ def filter_values_handler(
def handle_single_value(v):
# backward compatibility with previous <select> components
if isinstance(v, str):
v = v.strip('\t\n \'"')
v = v.strip('\t\n\'"')
if target_column_is_numeric:
# For backwards compatibility and edge cases
# where a column data type might have changed
Expand Down
9 changes: 8 additions & 1 deletion tests/druid_func_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,12 +234,19 @@ def test_get_filters_handles_none_for_string_types(self):
self.assertIsNone(res)

def test_get_filters_extracts_values_in_quotes(self):
filtr = {'col': 'A', 'op': 'in', 'val': [' "a" ']}
filtr = {'col': 'A', 'op': 'in', 'val': ['"a"']}
col = DruidColumn(column_name='A')
column_dict = {'A': col}
res = DruidDatasource.get_filters([filtr], [], column_dict)
self.assertEqual('a', res.filter['filter']['value'])

def test_get_filters_keeps_trailing_spaces(self):
filtr = {'col': 'A', 'op': 'in', 'val': ['a ']}
col = DruidColumn(column_name='A')
column_dict = {'A': col}
res = DruidDatasource.get_filters([filtr], [], column_dict)
self.assertEqual('a ', res.filter['filter']['value'])

def test_get_filters_converts_strings_to_num(self):
filtr = {'col': 'A', 'op': 'in', 'val': ['6']}
col = DruidColumn(column_name='A')
Expand Down

0 comments on commit 722043c

Please sign in to comment.