Browse Source

Merge pull request #4922 from nocodb/fix/filter-not-like-and-not-empty

Fix: Filter - include null values in not like filter result
pull/4923/head
Raju Udava 2 years ago committed by GitHub
parent
commit
2cf514e504
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      packages/nc-gui/utils/filterUtils.ts
  2. 9
      packages/nocodb/src/lib/db/sql-data-mapper/lib/sql/conditionV2.ts

4
packages/nc-gui/utils/filterUtils.ts

@ -41,13 +41,13 @@ export const comparisonOpList: {
text: 'is empty',
value: 'empty',
ignoreVal: true,
excludedTypes: [UITypes.Checkbox, UITypes.Rating],
excludedTypes: [UITypes.Checkbox, UITypes.Rating, UITypes.Number, UITypes.Decimal, UITypes.Percent, UITypes.Currency],
},
{
text: 'is not empty',
value: 'notempty',
ignoreVal: true,
excludedTypes: [UITypes.Checkbox, UITypes.Rating],
excludedTypes: [UITypes.Checkbox, UITypes.Rating, UITypes.Number, UITypes.Decimal, UITypes.Percent, UITypes.Currency],
},
{
text: 'is null',

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