mirror of
https://github.com/apache/superset.git
synced 2024-09-17 11:09:47 -04:00
Parse filter values for possible integers and floats (#2263)
This commit is contained in:
parent
4d900c9ee1
commit
ec1f0221cd
@ -1393,6 +1393,7 @@ class SqlaTable(Model, Datasource, AuditMixinNullable, ImportMixin):
|
||||
col_obj = cols[col]
|
||||
if op in ('in', 'not in'):
|
||||
values = [types.strip("'").strip('"') for types in eq]
|
||||
values = [utils.js_string_to_num(s) for s in values]
|
||||
cond = col_obj.sqla_col.in_(values)
|
||||
if op == 'not in':
|
||||
cond = ~cond
|
||||
@ -2574,6 +2575,7 @@ class DruidDatasource(Model, AuditMixinNullable, Datasource, ImportMixin):
|
||||
fields = []
|
||||
# Distinguish quoted values with regular value types
|
||||
values = [types.replace("'", '') for types in eq]
|
||||
values = [utils.js_string_to_num(s) for s in values]
|
||||
if len(values) > 1:
|
||||
for s in values:
|
||||
s = s.strip()
|
||||
|
@ -126,6 +126,14 @@ class memoized(object): # noqa
|
||||
def js_string_to_python(item):
|
||||
return None if item in ('null', 'undefined') else item
|
||||
|
||||
def js_string_to_num(item):
|
||||
if item.isdigit():
|
||||
return int(item)
|
||||
s = item
|
||||
try:
|
||||
s = float(item)
|
||||
except ValueError:
|
||||
return s
|
||||
|
||||
class DimSelector(Having):
|
||||
def __init__(self, **args):
|
||||
|
Loading…
Reference in New Issue
Block a user