diff --git a/packages/nocodb/src/lib/db/sql-data-mapper/lib/sql/conditionV2.ts b/packages/nocodb/src/lib/db/sql-data-mapper/lib/sql/conditionV2.ts index 354a8f8f8f..4238c5bb93 100644 --- a/packages/nocodb/src/lib/db/sql-data-mapper/lib/sql/conditionV2.ts +++ b/packages/nocodb/src/lib/db/sql-data-mapper/lib/sql/conditionV2.ts @@ -281,7 +281,7 @@ const parseConditionV2 = async ( return; } - if (isNumericCol(column.uidt)) { + if (isNumericCol(column.uidt) && typeof val === 'string') { // convert to number val = +val; } @@ -308,8 +308,8 @@ const parseConditionV2 = async ( } else { qb = qb.where(field, val); } - if (column.uidt === UITypes.Rating && val === 0) { - // unset rating is considered as NULL + if (isNumericCol(column.uidt) && val === 0) { + // unset number is considered as NULL qb = qb.orWhereNull(field); } break; @@ -331,8 +331,8 @@ const parseConditionV2 = async ( .whereNot(field, val) .orWhereNull(customWhereClause ? _val : _field); }); - } else if (column.uidt === UITypes.Rating) { - // unset rating is considered as NULL + } else if (isNumericCol(column.uidt)) { + // unset number is considered as NULL if (val === 0) { qb = qb.whereNot(field, val).whereNotNull(field); } else { @@ -342,7 +342,7 @@ const parseConditionV2 = async ( // mysql is case-insensitive for strings, turn to case-sensitive qb = qb.where((nestedQb) => { nestedQb.whereRaw('BINARY ?? != ?', [field, val]); - if (column.uidt !== UITypes.Rating) { + if (!isNumericCol(column.uidt)) { nestedQb.orWhereNull(customWhereClause ? _val : _field); } }); @@ -463,7 +463,7 @@ const parseConditionV2 = async ( case 'gt': const gt_op = customWhereClause ? '<' : '>'; qb = qb.where(field, gt_op, val); - if (column.uidt === UITypes.Rating) { + if (isNumericCol(column.uidt)) { if (gt_op === '<' && val > 0) { qb = qb.orWhereNull(field); } @@ -473,7 +473,7 @@ const parseConditionV2 = async ( case 'gte': const ge_op = customWhereClause ? '<=' : '>='; qb = qb.where(field, ge_op, val); - if (column.uidt === UITypes.Rating) { + if (isNumericCol(column.uidt)) { if (ge_op === '<=' || (ge_op === '>=' && val === 0)) { qb = qb.orWhereNull(field); } @@ -518,7 +518,7 @@ const parseConditionV2 = async ( case 'lt': const lt_op = customWhereClause ? '>' : '<'; qb = qb.where(field, lt_op, val); - if (column.uidt === UITypes.Rating) { + if (isNumericCol(column.uidt)) { if (lt_op === '<' && val > 0) { qb = qb.orWhereNull(field); } @@ -528,7 +528,7 @@ const parseConditionV2 = async ( case 'lte': const le_op = customWhereClause ? '>=' : '<='; qb = qb.where(field, le_op, val); - if (column.uidt === UITypes.Rating) { + if (isNumericCol(column.uidt)) { if (le_op === '<=' || (le_op === '>=' && val === 0)) { qb = qb.orWhereNull(field); }