superset-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From michel...@apache.org
Subject [incubator-superset] 04/08: Allow trailing spaces in simple filter values (#7617)
Date Sat, 08 Jun 2019 01:00:03 GMT
This is an automated email from the ASF dual-hosted git repository.

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

commit 2b6e8f57278d7aafb6d21bb774dbbb38b875d278
Author: Erik Ritter <erik.ritter@airbnb.com>
AuthorDate: Fri May 31 17:06:41 2019 -0700

    Allow trailing spaces in simple filter values (#7617)
    
    
    (cherry picked from commit 722043c67276e1bb72bf297eaa3cf37d3ce83ee0)
---
 superset/connectors/base/models.py | 2 +-
 tests/druid_func_tests.py          | 9 ++++++++-
 2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/superset/connectors/base/models.py b/superset/connectors/base/models.py
index eed92a6..ac4016d 100644
--- a/superset/connectors/base/models.py
+++ b/superset/connectors/base/models.py
@@ -220,7 +220,7 @@ class BaseDatasource(AuditMixinNullable, ImportMixin):
         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
diff --git a/tests/druid_func_tests.py b/tests/druid_func_tests.py
index cf0c5e9..b6fe46c 100644
--- a/tests/druid_func_tests.py
+++ b/tests/druid_func_tests.py
@@ -234,12 +234,19 @@ class DruidFuncTestCase(unittest.TestCase):
         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')


Mime
View raw message