Browse Source

fix(nocodb): empty result when identifier is null

pull/4644/head
Wing-Kam Wong 2 years ago
parent
commit
1102be7cf8
  1. 14
      packages/nocodb/src/lib/db/sql-data-mapper/lib/sql/formulav2/formulaQueryBuilderv2.ts

14
packages/nocodb/src/lib/db/sql-data-mapper/lib/sql/formulav2/formulaQueryBuilderv2.ts

@ -664,6 +664,20 @@ export default async function formulaQueryBuilderv2(
sql = `COALESCE(${left}, '') ${pt.operator} COALESCE(${right},'')${colAlias}`; sql = `COALESCE(${left}, '') ${pt.operator} COALESCE(${right},'')${colAlias}`;
} }
if (knex.clientType() === 'mysql2') {
sql = `IFNULL(${left} ${pt.operator} ${right}, ${
pt.operator === '='
? pt.left.type === 'Literal'
? pt.left.value === ''
: pt.right.value === ''
: pt.operator === '!='
? pt.left.type !== 'Literal'
? pt.left.value === ''
: pt.right.value === ''
: 0
}) ${colAlias}`;
}
const query = knex.raw(sql); const query = knex.raw(sql);
if (prevBinaryOp && pt.operator !== prevBinaryOp) { if (prevBinaryOp && pt.operator !== prevBinaryOp) {
query.wrap('(', ')'); query.wrap('(', ')');

Loading…
Cancel
Save