mirror of
https://github.com/apache/superset.git
synced 2026-04-16 22:55:52 +00:00
empty lists are invalid comparators (#5160)
This commit is contained in:
@@ -112,6 +112,26 @@ describe('AdhocFilter', () => {
|
||||
});
|
||||
// eslint-disable-next-line no-unused-expressions
|
||||
expect(adhocFilter3.isValid()).to.be.false;
|
||||
|
||||
const adhocFilter4 = new AdhocFilter({
|
||||
expressionType: EXPRESSION_TYPES.SIMPLE,
|
||||
subject: 'value',
|
||||
operator: 'in',
|
||||
comparator: [],
|
||||
clause: CLAUSES.WHERE,
|
||||
});
|
||||
// eslint-disable-next-line no-unused-expressions
|
||||
expect(adhocFilter4.isValid()).to.be.false;
|
||||
|
||||
const adhocFilter5 = new AdhocFilter({
|
||||
expressionType: EXPRESSION_TYPES.SIMPLE,
|
||||
subject: 'value',
|
||||
operator: 'in',
|
||||
comparator: ['val1'],
|
||||
clause: CLAUSES.WHERE,
|
||||
});
|
||||
// eslint-disable-next-line no-unused-expressions
|
||||
expect(adhocFilter5.isValid()).to.be.true;
|
||||
});
|
||||
|
||||
it('can translate from simple expressions to sql expressions', () => {
|
||||
|
||||
@@ -83,7 +83,13 @@ export default class AdhocFilter {
|
||||
|
||||
isValid() {
|
||||
if (this.expressionType === EXPRESSION_TYPES.SIMPLE) {
|
||||
return !!(this.operator && this.subject && this.comparator && this.clause);
|
||||
return !!(
|
||||
this.operator &&
|
||||
this.subject &&
|
||||
this.comparator &&
|
||||
this.comparator.length > 0 &&
|
||||
this.clause
|
||||
);
|
||||
} else if (this.expressionType === EXPRESSION_TYPES.SQL) {
|
||||
return !!(this.sqlExpression && this.clause);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user