Browse Source

fix(nocodb): blank logic on lookup columns

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

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

@ -633,6 +633,15 @@ async function generateLookupCondition(
qb.select(`${alias}.${childColumn.column_name}`);
if (filter.comparison_op === 'blank') {
return (qbP: Knex.QueryBuilder) => {
qbP.whereNotIn(childColumn.column_name, qb);
};
} else if (filter.comparison_op === 'notblank') {
return (qbP: Knex.QueryBuilder) => {
qbP.whereIn(childColumn.column_name, qb);
};
} else {
await nestedConditionJoin(
{
...filter,
@ -646,6 +655,7 @@ async function generateLookupCondition(
alias,
aliasCount
);
}
return (qbP: Knex.QueryBuilder) => {
if (filter.comparison_op in negatedMapping)
@ -656,6 +666,15 @@ async function generateLookupCondition(
qb = knex(`${parentModel.table_name} as ${alias}`);
qb.select(`${alias}.${parentColumn.column_name}`);
if (filter.comparison_op === 'blank') {
return (qbP: Knex.QueryBuilder) => {
qbP.whereNotIn(childColumn.column_name, qb);
};
} else if (filter.comparison_op === 'notblank') {
return (qbP: Knex.QueryBuilder) => {
qbP.whereIn(childColumn.column_name, qb);
};
} else {
await nestedConditionJoin(
{
...filter,
@ -669,6 +688,7 @@ async function generateLookupCondition(
alias,
aliasCount
);
}
return (qbP: Knex.QueryBuilder) => {
if (filter.comparison_op in negatedMapping)
@ -690,6 +710,15 @@ async function generateLookupCondition(
`${childAlias}.${parentColumn.column_name}`
);
if (filter.comparison_op === 'blank') {
return (qbP: Knex.QueryBuilder) => {
qbP.whereNotIn(childColumn.column_name, qb);
};
} else if (filter.comparison_op === 'notblank') {
return (qbP: Knex.QueryBuilder) => {
qbP.whereIn(childColumn.column_name, qb);
};
} else {
await nestedConditionJoin(
{
...filter,
@ -703,6 +732,7 @@ async function generateLookupCondition(
childAlias,
aliasCount
);
}
return (qbP: Knex.QueryBuilder) => {
if (filter.comparison_op in negatedMapping)

Loading…
Cancel
Save