mirror of
https://github.com/nocodb/nocodb.git
synced 2026-04-25 01:35:17 +00:00
Merge pull request #2204 from nocodb/fix/formula-filter
fix: formula filter
This commit is contained in:
@@ -203,12 +203,13 @@ 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;
|
||||
|
||||
return qb => {
|
||||
switch (filter.comparison_op) {
|
||||
case 'eq':
|
||||
@@ -218,17 +219,29 @@ const parseConditionV2 = async (
|
||||
qb = qb.whereNot(field, val);
|
||||
break;
|
||||
case 'like':
|
||||
if (column.uidt === UITypes.Formula) {
|
||||
[field, val] = [val, field];
|
||||
val = `%${val}%`.replace(/^%'([\s\S]*)'%$/, '%$1%')
|
||||
} else {
|
||||
val = `%${val}%`;
|
||||
}
|
||||
qb = qb.where(
|
||||
field,
|
||||
qb?.client?.config?.client === 'pg' ? 'ilike' : 'like',
|
||||
`%${val}%`
|
||||
val
|
||||
);
|
||||
break;
|
||||
case 'nlike':
|
||||
if (column.uidt === UITypes.Formula) {
|
||||
[field, val] = [val, field];
|
||||
val = `%${val}%`.replace(/^%'([\s\S]*)'%$/, '%$1%')
|
||||
} else {
|
||||
val = `%${val}%`;
|
||||
}
|
||||
qb = qb.whereNot(
|
||||
field,
|
||||
qb?.client?.config?.client === 'pg' ? 'ilike' : 'like',
|
||||
`%${val}%`
|
||||
val
|
||||
);
|
||||
break;
|
||||
case 'gt':
|
||||
@@ -273,9 +286,15 @@ const parseConditionV2 = async (
|
||||
break;
|
||||
|
||||
case 'empty':
|
||||
if (column.uidt === UITypes.Formula) {
|
||||
[field, val] = [val, field];
|
||||
}
|
||||
qb = qb.where(field, val);
|
||||
break;
|
||||
case 'notempty':
|
||||
if (column.uidt === UITypes.Formula) {
|
||||
[field, val] = [val, field];
|
||||
}
|
||||
qb = qb.whereNot(field, val);
|
||||
break;
|
||||
case 'null':
|
||||
|
||||
Reference in New Issue
Block a user