From db8bc5f6d5c101b20c6e946342b0fdc31b49e7d5 Mon Sep 17 00:00:00 2001 From: Wing-Kam Wong Date: Thu, 16 Feb 2023 12:19:51 +0800 Subject: [PATCH] fix(nocodb): add orWhere empty string for non-numeric cols --- .../db/sql-data-mapper/lib/sql/conditionV2.ts | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) 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 215b078ca4..14da71d3df 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 @@ -8,7 +8,7 @@ import genRollupSelectv2 from './genRollupSelectv2'; import RollupColumn from '../../../../models/RollupColumn'; import formulaQueryBuilderv2 from './formulav2/formulaQueryBuilderv2'; import FormulaColumn from '../../../../models/FormulaColumn'; -import { RelationTypes, UITypes } from 'nocodb-sdk'; +import { RelationTypes, UITypes, isNumericCol } from 'nocodb-sdk'; import { sanitize } from './helpers/sanitize'; export default async function conditionV2( @@ -281,7 +281,7 @@ const parseConditionV2 = async ( return; } - if (column.uidt === UITypes.Rating) { + if (isNumericCol(column.uidt)) { // convert to number val = +val; } @@ -559,7 +559,10 @@ const parseConditionV2 = async ( .orWhere(field, '[]') .orWhere(field, 'null'); } else { - qb = qb.whereNull(customWhereClause || field).orWhere(field, ''); + qb = qb.whereNull(customWhereClause || field); + if (!isNumericCol(column.uidt)) { + qb = qb.orWhere(field, ''); + } } break; case 'notblank': @@ -569,9 +572,10 @@ const parseConditionV2 = async ( .whereNot(field, '[]') .whereNot(field, 'null'); } else { - qb = qb - .whereNotNull(customWhereClause || field) - .whereNot(field, ''); + qb = qb.whereNotNull(customWhereClause || field); + if (!isNumericCol(column.uidt)) { + qb = qb.orWhere(field, ''); + } } break; case 'checked':