mirror of https://github.com/apache/superset.git
Allow trailing spaces in simple filter values (#7617)
This commit is contained in:
parent
15d0361148
commit
722043c672
|
@ -220,7 +220,7 @@ class BaseDatasource(AuditMixinNullable, ImportMixin):
|
||||||
def handle_single_value(v):
|
def handle_single_value(v):
|
||||||
# backward compatibility with previous <select> components
|
# backward compatibility with previous <select> components
|
||||||
if isinstance(v, str):
|
if isinstance(v, str):
|
||||||
v = v.strip('\t\n \'"')
|
v = v.strip('\t\n\'"')
|
||||||
if target_column_is_numeric:
|
if target_column_is_numeric:
|
||||||
# For backwards compatibility and edge cases
|
# For backwards compatibility and edge cases
|
||||||
# where a column data type might have changed
|
# where a column data type might have changed
|
||||||
|
|
|
@ -234,12 +234,19 @@ class DruidFuncTestCase(unittest.TestCase):
|
||||||
self.assertIsNone(res)
|
self.assertIsNone(res)
|
||||||
|
|
||||||
def test_get_filters_extracts_values_in_quotes(self):
|
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')
|
col = DruidColumn(column_name='A')
|
||||||
column_dict = {'A': col}
|
column_dict = {'A': col}
|
||||||
res = DruidDatasource.get_filters([filtr], [], column_dict)
|
res = DruidDatasource.get_filters([filtr], [], column_dict)
|
||||||
self.assertEqual('a', res.filter['filter']['value'])
|
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):
|
def test_get_filters_converts_strings_to_num(self):
|
||||||
filtr = {'col': 'A', 'op': 'in', 'val': ['6']}
|
filtr = {'col': 'A', 'op': 'in', 'val': ['6']}
|
||||||
col = DruidColumn(column_name='A')
|
col = DruidColumn(column_name='A')
|
||||||
|
|
Loading…
Reference in New Issue