From 9c6bb95ce7172da2eab2c841ad6de33fe693b57f Mon Sep 17 00:00:00 2001 From: Pranav C Date: Sat, 23 Dec 2023 08:12:11 +0000 Subject: [PATCH] fix: add support to negative numbers(- unary operator) --- packages/nocodb-sdk/src/lib/formulaHelpers.ts | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/packages/nocodb-sdk/src/lib/formulaHelpers.ts b/packages/nocodb-sdk/src/lib/formulaHelpers.ts index b92a15e302..97cd9f70e0 100644 --- a/packages/nocodb-sdk/src/lib/formulaHelpers.ts +++ b/packages/nocodb-sdk/src/lib/formulaHelpers.ts @@ -1777,11 +1777,14 @@ export async function validateFormulaAndExtractTreeWithType({ res.dataType = FormulaDataTypes.STRING; } } else if (parsedTree.type === JSEPNode.UNARY_EXP) { - throw new FormulaError( - FormulaErrorType.NOT_SUPPORTED, - {}, - 'Unary expression is not supported' - ); + // only support unary +/- + if (!['-', '+'].includes(parsedTree.operator)) { + throw new FormulaError( + FormulaErrorType.NOT_SUPPORTED, + {}, + `Unary expression '${parsedTree.operator}' is not supported` + ); + } } else if (parsedTree.type === JSEPNode.BINARY_EXP) { res.left = await validateAndExtract(parsedTree.left); res.right = await validateAndExtract(parsedTree.right);