Browse Source

fix: support all types if expected type is string

pull/7446/head
Pranav C 9 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 res: {
dataType?: FormulaDataTypes;
transform?: FormulaDataTypes;
errors?: Set<string>;
[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;
}
}
}

Loading…
Cancel
Save