Browse Source

Merge pull request #6935 from nocodb/fix/filter-issues

fix: Issues related to filter
pull/6932/head
Raju Udava 1 year ago committed by GitHub
parent
commit
ac62e72d60
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 23
      packages/nocodb/src/db/BaseModelSqlv2.ts
  2. 28
      packages/nocodb/src/db/conditionV2.ts

23
packages/nocodb/src/db/BaseModelSqlv2.ts

@ -5111,6 +5111,29 @@ export function extractCondition(
[logicOp, alias, op, value] =
str.match(/(?:~(and|or|not))?\((.*?),(\w+)\)/)?.slice(1) || [];
}
// handle isblank and isnotblank filter format
switch (op) {
case 'is':
if (value === 'blank') {
op = 'blank';
value = undefined;
} else if (value === 'notblank') {
op = 'notblank';
value = undefined;
}
break;
case 'isblank':
case 'is_blank':
op = 'blank';
break;
case 'isnotblank':
case 'is_not_blank':
case 'is_notblank':
op = 'notblank';
break;
}
let sub_op = null;
if (aliasColObjMap[alias]) {

28
packages/nocodb/src/db/conditionV2.ts

@ -257,9 +257,13 @@ const parseConditionV2 = async (
)(selectQb);
return (qbP: Knex.QueryBuilder) => {
if (filter.comparison_op in negatedMapping)
qbP.whereNotIn(childColumn.column_name, selectQb);
else qbP.whereIn(childColumn.column_name, selectQb);
if (filter.comparison_op in negatedMapping) {
qbP.where((qb) =>
qb
.whereNotIn(childColumn.column_name, selectQb)
.orWhereNull(childColumn.column_name),
);
} else qbP.whereIn(childColumn.column_name, selectQb);
};
} else if (colOptions.type === RelationTypes.MANY_TO_MANY) {
const mmModel = await colOptions.getMMModel();
@ -337,7 +341,11 @@ const parseConditionV2 = async (
return (qbP: Knex.QueryBuilder) => {
if (filter.comparison_op in negatedMapping)
qbP.whereNotIn(childColumn.column_name, selectQb);
qbP.where((qb) =>
qbP
.whereNotIn(childColumn.column_name, selectQb)
.orWhereNull(childColumn.column_name),
);
else qbP.whereIn(childColumn.column_name, selectQb);
};
}
@ -954,7 +962,11 @@ async function generateLookupCondition(
return (qbP: Knex.QueryBuilder) => {
if (filter.comparison_op in negatedMapping)
qbP.whereNotIn(childColumn.column_name, qb);
qbP.where((qb1) =>
qb1
.whereNotIn(childColumn.column_name, qb)
.orWhereNull(childColumn.column_name),
);
else qbP.whereIn(childColumn.column_name, qb);
};
} else if (relationColumnOptions.type === RelationTypes.MANY_TO_MANY) {
@ -992,7 +1004,11 @@ async function generateLookupCondition(
return (qbP: Knex.QueryBuilder) => {
if (filter.comparison_op in negatedMapping)
qbP.whereNotIn(childColumn.column_name, qb);
qbP.where((qb1) =>
qb1
.whereNotIn(childColumn.column_name, qb)
.orWhereNull(childColumn.column_name),
);
else qbP.whereIn(childColumn.column_name, qb);
};
}

Loading…
Cancel
Save