diff --git a/packages/nocodb-sdk/src/lib/formulaHelpers.ts b/packages/nocodb-sdk/src/lib/formulaHelpers.ts index 2958f7dcd8..1f4735ff6b 100644 --- a/packages/nocodb-sdk/src/lib/formulaHelpers.ts +++ b/packages/nocodb-sdk/src/lib/formulaHelpers.ts @@ -1249,6 +1249,10 @@ async function extractColumnIdentifierType({ errors?: Set; [p: string]: any; } = {}; + const sqlUI = + typeof clientOrSqlUi === 'string' + ? SqlUiFactory.create({ client: clientOrSqlUi }) + : clientOrSqlUi; switch (col?.uidt) { // string @@ -1342,10 +1346,6 @@ async function extractColumnIdentifierType({ case UITypes.ForeignKey: case UITypes.SpecificDBType: { - const sqlUI = - typeof clientOrSqlUi === 'string' - ? SqlUiFactory.create({ client: clientOrSqlUi }) - : clientOrSqlUi; if (sqlUI) { const abstractType = sqlUI.getAbstractType(col); if (['integer', 'float', 'decimal'].includes(abstractType)) { @@ -1405,6 +1405,11 @@ export async function validateFormulaAndExtractTreeWithType({ column?: ColumnType; getMeta: (tableId: string) => Promise; }) { + const sqlUI = + typeof clientOrSqlUi === 'string' + ? SqlUiFactory.create({ client: clientOrSqlUi }) + : clientOrSqlUi; + const colAliasToColMap = {}; const colIdToColMap = {}; @@ -1423,11 +1428,11 @@ export async function validateFormulaAndExtractTreeWithType({ if (parsedTree.type === JSEPNode.CALL_EXP) { const calleeName = parsedTree.callee.name.toUpperCase(); // validate function name - if (!formulas[calleeName]) { + if (!formulas[calleeName] || sqlUI?.getUnsupportedFnList().includes(calleeName)) { throw new FormulaError( FormulaErrorType.INVALID_FUNCTION_NAME, {}, - 'Function not available' + `Function ${calleeName} is not available` ); }