Browse Source

fix: wrap with boolean function if type is boolean to avoid any issue while comparing

pull/7437/head
Pranav C 10 months ago
parent
commit
fe748106df
  1. 4
      packages/nocodb-sdk/src/lib/formulaHelpers.ts
  2. 18
      packages/nocodb/src/db/formulav2/formulaQueryBuilderv2.ts

4
packages/nocodb-sdk/src/lib/formulaHelpers.ts

@ -1594,7 +1594,11 @@ async function extractColumnIdentifierType({
res.dataType = FormulaDataTypes.STRING;
break;
case UITypes.Checkbox:
if (col.dt === 'boolean' || col.dt === 'bool') {
res.dataType = FormulaDataTypes.BOOLEAN;
} else {
res.dataType = FormulaDataTypes.NUMERIC;
}
break;
case UITypes.ID:
case UITypes.ForeignKey:

18
packages/nocodb/src/db/formulav2/formulaQueryBuilderv2.ts

@ -889,20 +889,26 @@ async function _formulaQueryBuilder(
// if operator is == or !=, then handle comparison with BLANK which should accept NULL and empty string
if (pt.operator === '==' || pt.operator === '!=') {
if (pt.left.callee?.name !== pt.right.callee?.name) {
// if left/right is BLANK, accept both NULL and empty string
for (const operand of ['left', 'right']) {
if (pt[operand].type === FormulaDataTypes.BOOLEAN) {
pt[operand] = {
if (
pt[operand].dataType === FormulaDataTypes.BOOLEAN &&
pt[operand === 'left' ? 'right' : 'left'].dataType ===
FormulaDataTypes.NUMERIC
) {
pt[operand === 'left' ? 'right' : 'left'] = {
type: 'CallExpression',
arguments: [pt[operand]],
arguments: [pt[operand === 'left' ? 'right' : 'left']],
callee: {
type: 'Identifier',
name: 'BOOLEAN',
},
dataType: FormulaDataTypes.BOOLEAN,
};
}
}
if (pt.left.callee?.name !== pt.right.callee?.name) {
// if left/right is BLANK, accept both NULL and empty string
for (const operand of ['left', 'right']) {
if (
pt[operand].type === 'CallExpression' &&
pt[operand].callee.name === 'BLANK'

Loading…
Cancel
Save