From 25066cd942df05408e1f2684985fb9417cc81887 Mon Sep 17 00:00:00 2001 From: Wing-Kam Wong Date: Mon, 30 May 2022 16:09:27 +0800 Subject: [PATCH] fix: swap field & val for like, nlike, empty & notempty only --- .../nocodb/src/lib/dataMapper/lib/sql/conditionV2.ts | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/packages/nocodb/src/lib/dataMapper/lib/sql/conditionV2.ts b/packages/nocodb/src/lib/dataMapper/lib/sql/conditionV2.ts index 5b1fd00747..d7c1f3abd8 100644 --- a/packages/nocodb/src/lib/dataMapper/lib/sql/conditionV2.ts +++ b/packages/nocodb/src/lib/dataMapper/lib/sql/conditionV2.ts @@ -210,10 +210,6 @@ const parseConditionV2 = async ( : column.column_name; let val = customWhereClause ? customWhereClause : filter.value; - if (column.uidt === UITypes.Formula) { - [field, val] = [val, field]; - } - return qb => { switch (filter.comparison_op) { case 'eq': @@ -224,6 +220,7 @@ const parseConditionV2 = async ( break; case 'like': if (column.uidt === UITypes.Formula) { + [field, val] = [val, field]; val = `%${val}%`.replace("%'", '%').replace("'%", '%'); } else { val = `%${val}%`; @@ -236,6 +233,7 @@ const parseConditionV2 = async ( break; case 'nlike': if (column.uidt === UITypes.Formula) { + [field, val] = [val, field]; val = `%${val}%`.replace("%'", '%').replace("'%", '%'); } else { val = `%${val}%`; @@ -288,9 +286,15 @@ const parseConditionV2 = async ( break; case 'empty': + if (column.uidt === UITypes.Formula) { + [field, val] = [val, field]; + } qb = qb.where(field, val); break; case 'notempty': + if (column.uidt === UITypes.Formula) { + [field, val] = [val, field]; + } qb = qb.whereNot(field, val); break; case 'null':