Browse Source

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

pull/7437/head
Pranav C 11 months ago
parent
commit
f8660204f0
  1. 11
      packages/nocodb/src/db/formulav2/formulaQueryBuilderv2.ts
  2. 3
      packages/nocodb/src/db/functionMappings/commonFns.ts
  3. 9
      packages/nocodb/src/db/functionMappings/pg.ts

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

@ -892,6 +892,17 @@ async function _formulaQueryBuilder(
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] = {
type: 'CallExpression',
arguments: [pt[operand]],
callee: {
type: 'Identifier',
name: 'BOOLEAN',
},
};
}
if (
pt[operand].type === 'CallExpression' &&
pt[operand].callee.name === 'BLANK'

3
packages/nocodb/src/db/functionMappings/commonFns.ts

@ -184,6 +184,9 @@ export default {
STRING(args: MapFnArgs) {
return args.fn(args.pt?.arguments?.[0]);
},
BOOLEAN(args: MapFnArgs) {
return args.fn(args.pt?.arguments?.[0]);
},
AND: async (args: MapFnArgs) => {
return {
builder: args.knex.raw(

9
packages/nocodb/src/db/functionMappings/pg.ts

@ -348,6 +348,15 @@ END ${colAlias}`,
),
};
},
BOOLEAN: async (args: MapFnArgs) => {
return {
builder: args.knex.raw(
`(${(await args.fn(args.pt.arguments[0])).builder})::boolean ${
args.colAlias
}`,
),
};
},
};
export default pg;

Loading…
Cancel
Save