diff --git a/packages/server/src/sdk/app/rows/search/internal/sqs.ts b/packages/server/src/sdk/app/rows/search/internal/sqs.ts index 4eca0e4c09..c92d186a37 100644 --- a/packages/server/src/sdk/app/rows/search/internal/sqs.ts +++ b/packages/server/src/sdk/app/rows/search/internal/sqs.ts @@ -62,7 +62,15 @@ async function buildInternalFieldList( ) { const { relationships, allowedFields } = opts || {} let schemaFields: string[] = [] + const isView = sdk.views.isView(source) + let table: Table + if (isView) { + table = await sdk.views.getTable(source.id) + } else { + table = source + } + if (isView) { schemaFields = Object.keys(helpers.views.basicFields(source)) } else { @@ -71,17 +79,16 @@ async function buildInternalFieldList( ) } - if (allowedFields) { + const containsFormula = schemaFields.some( + f => table.schema[f]?.type === FieldType.FORMULA + ) + // If are requesting for a formula field, we need to retrieve all fields + if (containsFormula) { + schemaFields = Object.keys(table.schema) + } else if (allowedFields) { schemaFields = schemaFields.filter(field => allowedFields.includes(field)) } - let table: Table - if (isView) { - table = await sdk.views.getTable(source.id) - } else { - table = source - } - let fieldList: string[] = [] const getJunctionFields = (relatedTable: Table, fields: string[]) => { const junctionFields: string[] = []