From b001bae5f47be1c5bde2fcf25c17ce7b6b919e48 Mon Sep 17 00:00:00 2001 From: Wing-Kam Wong Date: Tue, 28 Feb 2023 13:34:30 +0800 Subject: [PATCH] fix(nocodb): cater undefined aliasColObjMap[alias] --- .../sql-data-mapper/lib/sql/BaseModelSqlv2.ts | 24 +++++++++++-------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/packages/nocodb/src/lib/db/sql-data-mapper/lib/sql/BaseModelSqlv2.ts b/packages/nocodb/src/lib/db/sql-data-mapper/lib/sql/BaseModelSqlv2.ts index 595a44893a..ac0decba89 100644 --- a/packages/nocodb/src/lib/db/sql-data-mapper/lib/sql/BaseModelSqlv2.ts +++ b/packages/nocodb/src/lib/db/sql-data-mapper/lib/sql/BaseModelSqlv2.ts @@ -3020,17 +3020,21 @@ function extractCondition(nestedArrayConditions, aliasColObjMap) { str.match(/(?:~(and|or|not))?\((.*?),(\w+),(.*)\)/)?.slice(1) || []; let sub_op = null; - if ([UITypes.Date, UITypes.DateTime].includes(aliasColObjMap[alias].uidt)) { - value = value.split(','); - // the first element would be sub_op - sub_op = value[0]; - // remove the first element which is sub_op - value.shift(); - } else if (op === 'in') { - value = value.split(','); - } + if (aliasColObjMap[alias]) { + if ( + [UITypes.Date, UITypes.DateTime].includes(aliasColObjMap[alias].uidt) + ) { + value = value.split(','); + // the first element would be sub_op + sub_op = value[0]; + // remove the first element which is sub_op + value.shift(); + } else if (op === 'in') { + value = value.split(','); + } - validateFilterComparison(aliasColObjMap[alias].uidt, op, sub_op); + validateFilterComparison(aliasColObjMap[alias].uidt, op, sub_op); + } return new Filter({ comparison_op: op,