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 RollupColumn from '../../../../models/RollupColumn';
import formulaQueryBuilderv2 from './formulav2/formulaQueryBuilderv2'; import formulaQueryBuilderv2 from './formulav2/formulaQueryBuilderv2';
import FormulaColumn from '../../../../models/FormulaColumn'; import FormulaColumn from '../../../../models/FormulaColumn';
import { RelationTypes, UITypes } from 'nocodb-sdk'; import { RelationTypes, UITypes, isNumericCol } from 'nocodb-sdk';
import { sanitize } from './helpers/sanitize'; import { sanitize } from './helpers/sanitize';
export default async function conditionV2( export default async function conditionV2(
@ -281,7 +281,7 @@ const parseConditionV2 = async (
return; return;
} }
if (column.uidt === UITypes.Rating) { if (isNumericCol(column.uidt)) {
// convert to number // convert to number
val = +val; val = +val;
} }
@ -559,7 +559,10 @@ const parseConditionV2 = async (
.orWhere(field, '[]') .orWhere(field, '[]')
.orWhere(field, 'null'); .orWhere(field, 'null');
} else { } else {
qb = qb.whereNull(customWhereClause || field).orWhere(field, ''); qb = qb.whereNull(customWhereClause || field);
if (!isNumericCol(column.uidt)) {
qb = qb.orWhere(field, '');
}
} }
break; break;
case 'notblank': case 'notblank':
@ -569,9 +572,10 @@ const parseConditionV2 = async (
.whereNot(field, '[]') .whereNot(field, '[]')
.whereNot(field, 'null'); .whereNot(field, 'null');
} else { } else {
qb = qb qb = qb.whereNotNull(customWhereClause || field);
.whereNotNull(customWhereClause || field) if (!isNumericCol(column.uidt)) {
.whereNot(field, ''); qb = qb.orWhere(field, '');
}
} }
break; break;
case 'checked': case 'checked':

Loading…
Cancel
Save