Skip to content

Commit

Permalink
Revert "[hotfix] Fix druid filters"
Browse files Browse the repository at this point in the history
  • Loading branch information
vera-liu committed Feb 28, 2017
1 parent 09f1083 commit b882d45
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 26 deletions.
Expand Up @@ -4,9 +4,6 @@ import Select from 'react-select';
import { Button, Row, Col } from 'react-bootstrap';
import SelectControl from './SelectControl';

const arrayFilterOps = ['in', 'not in'];
const strFilterOps = ['==', '!=', '>', '<', '>=', '<=', 'regex'];

const propTypes = {
choices: PropTypes.array,
changeFilter: PropTypes.func,
Expand Down Expand Up @@ -58,15 +55,6 @@ export default class Filter extends React.Component {
if (event && event.value) {
value = event.value;
}
if (control === 'op') {
if (arrayFilterOps.indexOf(this.props.filter.op) !== -1
&& strFilterOps.indexOf(value) !== -1) {
this.props.changeFilter('val', this.props.filter.val[0]);
} else if (strFilterOps.indexOf(this.props.filter.op) !== -1
&& arrayFilterOps.indexOf(value) !== -1) {
this.props.changeFilter('val', [this.props.filter.val]);
}
}
this.props.changeFilter(control, value);
if (control === 'col' && value !== null && this.props.datasource.filter_select) {
this.fetchFilterValues(value);
Expand All @@ -82,13 +70,13 @@ export default class Filter extends React.Component {
this.fetchFilterValues(filter.col);
}
}
if (this.props.having || StrFilterOps.indexOf(filter.op) !== -1) {
// druid having filter or regex/==/!= filters
if (this.props.having) {
// druid having filter
return (
<input
type="text"
onChange={this.changeFilter.bind(this, 'val')}
value={filter.val}
value={filter.value}
className="form-control input-sm"
placeholder="Filter value"
/>
Expand Down
15 changes: 4 additions & 11 deletions superset/models.py
Expand Up @@ -1403,8 +1403,7 @@ def visit_column(element, compiler, **kw):
col_obj = cols.get(col)
if col_obj and op in ('in', 'not in'):
values = [types.strip("'").strip('"') for types in eq]
if col_obj.is_num:
values = [utils.js_string_to_num(s) for s in values]
values = [utils.js_string_to_num(s) for s in values]
cond = col_obj.sqla_col.in_(values)
if op == 'not in':
cond = ~cond
Expand Down Expand Up @@ -2568,7 +2567,8 @@ def increment_timestamp(ts):
query=query_str,
duration=datetime.now() - qry_start_dttm)

def get_filters(self, raw_filters):
@staticmethod
def get_filters(raw_filters):
filters = None
for flt in raw_filters:
if not all(f in flt for f in ['col', 'op', 'val']):
Expand All @@ -2577,11 +2577,6 @@ def get_filters(self, raw_filters):
op = flt['op']
eq = flt['val']
cond = None
if col in self.num_cols:
if op in ('in', 'not in'):
eq = [utils.js_string_to_num(v) for v in eq]
else:
eq = utils.js_string_to_num(eq)
if op == '==':
cond = Dimension(col) == eq
elif op == '!=':
Expand All @@ -2590,9 +2585,7 @@ def get_filters(self, raw_filters):
fields = []
# Distinguish quoted values with regular value types
values = [types.replace("'", '') for types in eq]
for val in eq:
if col in self.num_cols:
val = utils.js_string_to_num(val)
values = [utils.js_string_to_num(s) for s in values]
if len(values) > 1:
for s in values:
s = s.strip()
Expand Down

0 comments on commit b882d45

Please sign in to comment.