Browse Source

fix(nocodb): add orWhere empty string for non-numeric cols

pull/4969/head
Wing-Kam Wong 2 years ago
parent
commit
db8bc5f6d5
  1. 16
      packages/nocodb/src/lib/db/sql-data-mapper/lib/sql/conditionV2.ts

16
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':

Loading…
Cancel
Save