Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion superset/assets/javascripts/explorev2/stores/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export function getControlsState(state, form_data) {
// Removing invalid filters that point to a now inexisting column
if (control.type === 'FilterControl' && control.choices) {
const choiceValues = control.choices.map(c => c[0]);
formData[k] = control.value.filter(flt => choiceValues.indexOf(flt.col) > 0);
formData[k] = formData[k].filter(flt => choiceValues.indexOf(flt.col) >= 0);
}

if (typeof control.default === 'function') {
Expand Down
15 changes: 5 additions & 10 deletions superset/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,6 @@ def __init__( # noqa
self.error_message = error_message


FilterPattern = re.compile(r'''((?:[^,"']|"[^"]*"|'[^']*')+)''')


def set_perm(mapper, connection, target): # noqa
if target.perm != target.get_perm():
link_table = target.__table__
Expand Down Expand Up @@ -1390,11 +1387,10 @@ def visit_column(element, compiler, **kw):
continue
col = flt['col']
op = flt['op']
eq = ','.join(flt['val'])
eq = flt['val']
col_obj = cols[col]
if op in ('in', 'not in'):
splitted = FilterPattern.split(eq)[1::2]
values = [types.strip("'").strip('"') for types in splitted]
values = [types.strip("'").strip('"') for types in eq]
cond = col_obj.sqla_col.in_(values)
if op == 'not in':
cond = ~cond
Expand Down Expand Up @@ -2554,15 +2550,14 @@ def get_filters(raw_filters):
elif op in ('in', 'not in'):
fields = []
# Distinguish quoted values with regular value types
split = FilterPattern.split(eq)[1::2]
values = [types.replace("'", '') for types in split]
values = [types.replace("'", '') for types in eq]
if len(values) > 1:
for s in values:
s = s.strip()
fields.append(Dimension(col) == s)
cond = Filter(type="or", fields=fields)
else:
cond = Dimension(col) == eq
elif len(values) == 1:
cond = Dimension(col) == eq[0]
if op == 'not in':
cond = ~cond
elif op == 'regex':
Expand Down