diff --git a/.run/Run__Backend_Cloud.run.xml b/.run/Run__Backend_Cloud.run.xml
index e797060ce5..35b3769425 100644
--- a/.run/Run__Backend_Cloud.run.xml
+++ b/.run/Run__Backend_Cloud.run.xml
@@ -13,4 +13,4 @@
-
\ No newline at end of file
+
diff --git a/packages/nocodb-sdk/src/lib/formulaHelpers.ts b/packages/nocodb-sdk/src/lib/formulaHelpers.ts
index ebbbb65ddd..2e352f6268 100644
--- a/packages/nocodb-sdk/src/lib/formulaHelpers.ts
+++ b/packages/nocodb-sdk/src/lib/formulaHelpers.ts
@@ -5,12 +5,26 @@ import {
FormulaType,
LinkToAnotherRecordType,
RollupType,
+ TableType,
} from './Api';
import UITypes from './UITypes';
import dayjs from 'dayjs';
-import { MssqlUi, MysqlUi, PgUi, SnowflakeUi, SqlUiFactory } from './sqlUi';
+import { SqlUiFactory } from './sqlUi';
import { dateFormats } from './dateTimeHelper';
+type SqlUI = ReturnType<(typeof SqlUiFactory)['create']>;
+type ClientTypeOrSqlUI =
+ | 'mysql'
+ | 'pg'
+ | 'sqlite3'
+ | 'mssql'
+ | 'mysql2'
+ | 'oracledb'
+ | 'mariadb'
+ | 'sqlite'
+ | 'snowflake'
+ | SqlUI;
+
export const StringOperators = ['||', '&'] as const;
export const ArithmeticOperators = ['+', '-', '*', '/'] as const;
export const ComparisonOperators = [
@@ -1572,7 +1586,7 @@ async function extractColumnIdentifierType({
col: Record;
columns: ColumnType[];
getMeta: (tableId: string) => Promise;
- clientOrSqlUi: any;
+ clientOrSqlUi: ClientTypeOrSqlUI;
}) {
const res: {
dataType?: FormulaDataTypes;
@@ -1727,20 +1741,7 @@ export async function validateFormulaAndExtractTreeWithType({
}: {
formula: string;
columns: ColumnType[];
- clientOrSqlUi:
- | 'mysql'
- | 'pg'
- | 'sqlite3'
- | 'mssql'
- | 'mysql2'
- | 'oracledb'
- | 'mariadb'
- | 'sqlite'
- | 'snowflake'
- | typeof MysqlUi
- | typeof MssqlUi
- | typeof SnowflakeUi
- | typeof PgUi;
+ clientOrSqlUi: ClientTypeOrSqlUI;
column?: ColumnType;
getMeta: (tableId: string) => Promise;
}): Promise {
@@ -1951,8 +1952,7 @@ export async function validateFormulaAndExtractTreeWithType({
column,
parsedTree,
columns,
- getMeta,
- sqlUI
+ getMeta
);
}
const formulaRes =
@@ -1970,7 +1970,7 @@ export async function validateFormulaAndExtractTreeWithType({
}
));
- res.dataType = (formulaRes as any)?.dataType;
+ res.dataType = (formulaRes as ParsedFormulaNode)?.dataType;
} else {
if (
col?.uidt === UITypes.Lookup ||
@@ -1982,8 +1982,7 @@ export async function validateFormulaAndExtractTreeWithType({
column,
parsedTree,
columns,
- getMeta,
- sqlUI
+ getMeta
);
}
}
@@ -2281,11 +2280,10 @@ function handleBinaryExpressionForDateAndTime(params: {
return res;
}
async function checkForCircularFormulaRef(
- formulaCol,
- parsedTree,
- columns,
- getMeta,
- _sqlUI
+ formulaCol: ColumnType,
+ parsedTree: ParsedFormulaNode,
+ columns: ColumnType[],
+ getMeta: (tableId: string) => Promise
) {
// Extract formula references
const formulaPaths = await columns.reduce(async (promiseRes, c) => {
@@ -2293,7 +2291,9 @@ async function checkForCircularFormulaRef(
if (c.id !== formulaCol.id && c.uidt === UITypes.Formula) {
const neighbours = [
...new Set(
- (c.colOptions.formula.match(/c_?\w{14,15}/g) || []).filter((colId) =>
+ (
+ (c.colOptions as FormulaType).formula.match(/c_?\w{14,15}/g) || []
+ ).filter((colId) =>
columns.some(
(col) => col.id === colId && col.uidt === UITypes.Formula
)
@@ -2381,7 +2381,7 @@ async function checkForCircularFormulaRef(
// include target formula column (i.e. the one to be saved if applicable)
const targetFormulaCol = columns.find(
(c: ColumnType) =>
- c.title === parsedTree.name &&
+ c.title === (parsedTree as IdentifierNode).name &&
[UITypes.Formula, UITypes.LinkToAnotherRecord, UITypes.Lookup].includes(
c.uidt as UITypes
)