Browse Source

fix: support all types if expected type is string

pull/7446/head
Pranav C 10 months ago
parent
commit
a622d9a621
  1. 12
      packages/nocodb-sdk/src/lib/formulaHelpers.ts

12
packages/nocodb-sdk/src/lib/formulaHelpers.ts

@ -1679,6 +1679,7 @@ export async function validateFormulaAndExtractTreeWithType({
const validateAndExtract = async (parsedTree: any) => { const validateAndExtract = async (parsedTree: any) => {
const res: { const res: {
dataType?: FormulaDataTypes; dataType?: FormulaDataTypes;
transform?: FormulaDataTypes;
errors?: Set<string>; errors?: Set<string>;
[key: string]: any; [key: string]: any;
} = { ...parsedTree }; } = { ...parsedTree };
@ -1763,7 +1764,8 @@ export async function validateFormulaAndExtractTreeWithType({
if ( if (
argPt.dataType !== expectedArgType && argPt.dataType !== expectedArgType &&
argPt.dataType !== FormulaDataTypes.NULL && argPt.dataType !== FormulaDataTypes.NULL &&
argPt.dataType !== FormulaDataTypes.UNKNOWN argPt.dataType !== FormulaDataTypes.UNKNOWN &&
expectedArgType !== FormulaDataTypes.STRING
) { ) {
if (argPt.type === JSEPNode.IDENTIFIER) { if (argPt.type === JSEPNode.IDENTIFIER) {
const name = 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;
}
} }
} }

Loading…
Cancel
Save