Browse Source

fix(nocodb): condition nlike logic

pull/5106/head
Wing-Kam Wong 2 years ago
parent
commit
625c59e2f5
  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

@ -297,11 +297,17 @@ const parseConditionV2 = async (
}
break;
case 'nlike':
if (!val) {
// val is empty -> include all values but empty strings
qb.whereNot(field, '');
qb.orWhereNull(field);
} else {
if (column.uidt === UITypes.Formula) {
[field, val] = [val, field];
val = `%${val}%`.replace(/^%'([\s\S]*)'%$/, '%$1%');
} else {
val = val.startsWith('%') || val.endsWith('%') ? val : `%${val}%`;
val =
val.startsWith('%') || val.endsWith('%') ? val : `%${val}%`;
}
qb.where((nestedQb) => {
if (qb?.client?.config?.client === 'pg') {
@ -309,8 +315,16 @@ const parseConditionV2 = async (
} else {
nestedQb.whereNot(field, 'like', val);
}
if (val !== '%%') {
// if value is not empty, empty or null should be included
nestedQb.orWhere(field, '');
nestedQb.orWhereNull(field);
} else {
// if value is empty, then only null is included
nestedQb.orWhereNull(field);
}
});
}
break;
case 'allof':
case 'anyof':

Loading…
Cancel
Save