Browse Source

fix(nocodb): attachment filter logic

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

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

@ -357,9 +357,16 @@ const parseConditionV2 = async (
break;
case 'like':
if (!val) {
if (column.uidt === UITypes.Attachment) {
qb = qb
.orWhereNull(field)
.orWhere(field, '[]')
.orWhere(field, 'null');
} else {
// val is empty -> all values including empty strings but NULL
qb.where(field, '');
qb.orWhereNotNull(field);
}
} else {
if (column.uidt === UITypes.Formula) {
[field, val] = [val, field];
@ -377,9 +384,15 @@ const parseConditionV2 = async (
break;
case 'nlike':
if (!val) {
if (column.uidt === UITypes.Attachment) {
qb.whereNot(field, '')
.whereNot(field, 'null')
.whereNot(field, '[]');
} else {
// val is empty -> all values including NULL but empty strings
qb.whereNot(field, '');
qb.orWhereNull(field);
}
} else {
if (column.uidt === UITypes.Formula) {
[field, val] = [val, field];
@ -540,12 +553,26 @@ const parseConditionV2 = async (
qb = qb.whereNotNull(customWhereClause || field);
break;
case 'blank':
if (column.uidt === UITypes.Attachment) {
qb = qb
.whereNull(customWhereClause || field)
.orWhere(field, '[]')
.orWhere(field, 'null');
} else {
qb = qb.whereNull(customWhereClause || field).orWhere(field, '');
}
break;
case 'notblank':
if (column.uidt === UITypes.Attachment) {
qb = qb
.whereNotNull(customWhereClause || field)
.whereNot(field, '[]')
.whereNot(field, 'null');
} else {
qb = qb
.whereNotNull(customWhereClause || field)
.whereNot(field, '');
}
break;
case 'checked':
qb = qb.where(customWhereClause || field, true);

Loading…
Cancel
Save