Browse Source

fix: formula filter - isEmpty / isNotEmpty / isLike / isNotLike

pull/2204/head
Wing-Kam Wong 3 years ago
parent
commit
4ee4dd87c8
  1. 23
      packages/nocodb/src/lib/dataMapper/lib/sql/conditionV2.ts

23
packages/nocodb/src/lib/dataMapper/lib/sql/conditionV2.ts

@ -203,12 +203,17 @@ const parseConditionV2 = async (
filter.comparison_op === 'notempty'
)
filter.value = '';
const field = customWhereClause
let field = customWhereClause
? filter.value
: alias
? `${alias}.${column.column_name}`
: column.column_name;
const val = customWhereClause ? customWhereClause : filter.value;
let val = customWhereClause ? customWhereClause : filter.value;
if (column.uidt === UITypes.Formula) {
[field, val] = [val, field];
}
return qb => {
switch (filter.comparison_op) {
case 'eq':
@ -218,17 +223,27 @@ const parseConditionV2 = async (
qb = qb.whereNot(field, val);
break;
case 'like':
if (column.uidt === UITypes.Formula) {
val = `%${val}%`.replace("%'", '%').replace("'%", '%');
} else {
val = `%${val}%`;
}
qb = qb.where(
field,
qb?.client?.config?.client === 'pg' ? 'ilike' : 'like',
`%${val}%`
val
);
break;
case 'nlike':
if (column.uidt === UITypes.Formula) {
val = `%${val}%`.replace("%'", '%').replace("'%", '%');
} else {
val = `%${val}%`;
}
qb = qb.whereNot(
field,
qb?.client?.config?.client === 'pg' ? 'ilike' : 'like',
`%${val}%`
val
);
break;
case 'gt':

Loading…
Cancel
Save