empty lists are invalid comparators (#5160)
This commit is contained in:
parent
57e125688f
commit
5b35f75cbf
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue