Browse Source

fix(api): in not like result include null values as well

Signed-off-by: Pranav C <pranavxc@gmail.com>
pull/4922/head
Pranav C 2 years ago
parent
commit
b5068334b5
  1. 9
      packages/nocodb/src/lib/db/sql-data-mapper/lib/sql/conditionV2.ts

9
packages/nocodb/src/lib/db/sql-data-mapper/lib/sql/conditionV2.ts

@ -303,16 +303,20 @@ const parseConditionV2 = async (
} else {
val = val.startsWith('%') || val.endsWith('%') ? val : `%${val}%`;
}
qb.where((nestedQb) => {
if (qb?.client?.config?.client === 'pg') {
qb = qb.whereRaw('??::text not ilike ?', [field, val]);
nestedQb.whereRaw('??::text not ilike ?', [field, val]);
} else {
qb = qb.whereNot(field, 'like', val);
nestedQb.whereNot(field, 'like', val);
}
nestedQb.orWhereNull(field);
});
break;
case 'allof':
case 'anyof':
case 'nallof':
case 'nanyof':
{
// Condition for filter, without negation
const condition = (builder: Knex.QueryBuilder) => {
const items = val.split(',').map((item) => item.trim());
@ -348,6 +352,7 @@ const parseConditionV2 = async (
} else {
qb = qb.whereNot(condition).orWhereNull(field);
}
}
break;
case 'gt':
qb = qb.where(field, customWhereClause ? '<' : '>', val);

Loading…
Cancel
Save