From a622d9a6217988dd143310284a20c8649eeb49c5 Mon Sep 17 00:00:00 2001 From: Pranav C Date: Wed, 17 Jan 2024 06:57:49 +0000 Subject: [PATCH] fix: support all types if expected type is string --- packages/nocodb-sdk/src/lib/formulaHelpers.ts | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/packages/nocodb-sdk/src/lib/formulaHelpers.ts b/packages/nocodb-sdk/src/lib/formulaHelpers.ts index b3cc06d364..90183336e9 100644 --- a/packages/nocodb-sdk/src/lib/formulaHelpers.ts +++ b/packages/nocodb-sdk/src/lib/formulaHelpers.ts @@ -1679,6 +1679,7 @@ export async function validateFormulaAndExtractTreeWithType({ const validateAndExtract = async (parsedTree: any) => { const res: { dataType?: FormulaDataTypes; + transform?: FormulaDataTypes; errors?: Set; [key: string]: any; } = { ...parsedTree }; @@ -1763,7 +1764,8 @@ export async function validateFormulaAndExtractTreeWithType({ if ( argPt.dataType !== expectedArgType && argPt.dataType !== FormulaDataTypes.NULL && - argPt.dataType !== FormulaDataTypes.UNKNOWN + argPt.dataType !== FormulaDataTypes.UNKNOWN && + expectedArgType !== FormulaDataTypes.STRING ) { if (argPt.type === JSEPNode.IDENTIFIER) { const name = @@ -1809,6 +1811,14 @@ export async function validateFormulaAndExtractTreeWithType({ ); } } + + // if expected type is string and arg type is not string, then transform it to string + if ( + expectedArgType === FormulaDataTypes.STRING && + expectedArgType !== argPt.dataType + ) { + argPt.transform = FormulaDataTypes.STRING; + } } }