Skip to content

Commit ac9c7f8

Browse files
authored
Merge branch 'master' into workflows
2 parents 24bbdfc + f37e791 commit ac9c7f8

File tree

2 files changed

+27
-2
lines changed

2 files changed

+27
-2
lines changed

projects/igniteui-angular/src/lib/data-operations/filtering-strategy.spec.ts

+24
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,30 @@ describe('Unit testing FilteringStrategy', () => {
4949
const res = fs.matchRecord(rec, expressionTree);
5050
expect(res).toBeTruthy();
5151
});
52+
it ('tests `findMatchByExpression` for working with filtering operands with missing condition', () => {
53+
const rec = data[0];
54+
const expressionTree = JSON.parse('{"filteringOperands":[{"fieldName":"Missing","condition":{"name":"notEmpty","isUnary":true,"iconName":"filter_not_empty"},"conditionName":"notEmpty","ignoreCase":true,"searchVal":null,"searchTree":null}],"operator":0,"returnFields":[],"type":1}');
55+
56+
57+
const res = fs.matchRecord(rec, expressionTree);
58+
expect(res).toBeFalsy();
59+
});
60+
61+
it ('no error when condition is missing in the filtering expressions tree', () => {
62+
const rec = data[0];
63+
const expressionTree = new FilteringExpressionsTree(FilteringLogic.Or);
64+
expressionTree.filteringOperands = [
65+
{
66+
conditionName: 'contains',
67+
fieldName: 'string',
68+
ignoreCase: false,
69+
searchVal: 'ROW'
70+
}
71+
];
72+
const res = fs.matchRecord(rec, expressionTree);
73+
expect(res).toBeFalsy();
74+
});
75+
5276
it ('tests `findMatch`', () => {
5377
const rec = data[0];
5478
const res = fs.findMatchByExpression(rec, {

projects/igniteui-angular/src/lib/data-operations/filtering-strategy.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,10 @@ export interface IgxFilterItem {
3939
export abstract class BaseFilteringStrategy implements IFilteringStrategy {
4040
// protected
4141
public findMatchByExpression(rec: any, expr: IFilteringExpression, isDate?: boolean, isTime?: boolean, grid?: GridType): boolean {
42-
const cond = expr.condition;
4342
const val = this.getFieldValue(rec, expr.fieldName, isDate, isTime, grid);
44-
return cond.logic(val, expr.searchVal, expr.ignoreCase);
43+
if (expr.condition?.logic) {
44+
return expr.condition.logic(val, expr.searchVal, expr.ignoreCase);
45+
}
4546
}
4647

4748
// protected

0 commit comments

Comments
 (0)