From 4e0770d1ab472d32a557a4d6bf9aaddc88b67264 Mon Sep 17 00:00:00 2001 From: Jan Prochazka Date: Sat, 25 Apr 2020 21:52:08 +0200 Subject: [PATCH] mix - more conditions --- packages/datalib/src/GridDisplay.ts | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/packages/datalib/src/GridDisplay.ts b/packages/datalib/src/GridDisplay.ts index 0f13e334..533776a0 100644 --- a/packages/datalib/src/GridDisplay.ts +++ b/packages/datalib/src/GridDisplay.ts @@ -117,6 +117,7 @@ export abstract class GridDisplay { } applyFilterOnSelect(select: Select, displayedColumnInfo: DisplayedColumnInfo) { + const conditions = []; for (const uniqueName in this.config.filters) { const filter = this.config.filters[uniqueName]; if (!filter) continue; @@ -125,20 +126,29 @@ export abstract class GridDisplay { try { const condition = parseFilter(filter, getFilterType(column.commonType?.typeCode)); if (condition) { - select.where = _.cloneDeepWith(condition, (expr: Expression) => { - if (expr.exprType == 'placeholder') - return { - exprType: 'column', - columnName: column.columnName, - source: { alias: column.sourceAlias }, - }; - }); + conditions.push( + _.cloneDeepWith(condition, (expr: Expression) => { + if (expr.exprType == 'placeholder') + return { + exprType: 'column', + columnName: column.columnName, + source: { alias: column.sourceAlias }, + }; + }) + ); } } catch (err) { console.warn(err.message); continue; } } + + if (conditions.length > 0) { + select.where = { + conditionType: 'and', + conditions, + }; + } } applySortOnSelect(select: Select, displayedColumnInfo: DisplayedColumnInfo) {