Skip to content

Commit

Permalink
Guess the filter value type (#1978)
Browse files Browse the repository at this point in the history
* Guess the filter value type

* Require quotes

* Use column type
  • Loading branch information
bkyryliuk authored Jan 24, 2017
1 parent e46ba2b commit cdbd2f8
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion superset/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from __future__ import print_function
from __future__ import unicode_literals

import ast
from collections import OrderedDict
import functools
import json
Expand Down Expand Up @@ -1350,7 +1351,12 @@ def visit_column(element, compiler, **kw):
col_obj = cols[col]
if op in ('in', 'not in'):
splitted = FillterPattern.split(eq)[1::2]
values = [types.replace("'", '').strip() for types in splitted]
values = [types.strip() for types in splitted]
# attempt to get the values type if they are not in quotes
if not col_obj.is_string:
values = [ast.literal_eval(v) for v in values]
else:
values = [v.replace("'", '').strip() for v in values]
cond = col_obj.sqla_col.in_(values)
if op == 'not in':
cond = ~cond
Expand Down

0 comments on commit cdbd2f8

Please sign in to comment.