Fix sqs formula

This commit is contained in:
Adria Navarro 2024-12-17 16:10:21 +01:00
parent 8eb82d3b05
commit 23531e1509
1 changed files with 15 additions and 8 deletions

View File

@ -62,7 +62,15 @@ async function buildInternalFieldList(
) { ) {
const { relationships, allowedFields } = opts || {} const { relationships, allowedFields } = opts || {}
let schemaFields: string[] = [] let schemaFields: string[] = []
const isView = sdk.views.isView(source) const isView = sdk.views.isView(source)
let table: Table
if (isView) {
table = await sdk.views.getTable(source.id)
} else {
table = source
}
if (isView) { if (isView) {
schemaFields = Object.keys(helpers.views.basicFields(source)) schemaFields = Object.keys(helpers.views.basicFields(source))
} else { } 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)) 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[] = [] let fieldList: string[] = []
const getJunctionFields = (relatedTable: Table, fields: string[]) => { const getJunctionFields = (relatedTable: Table, fields: string[]) => {
const junctionFields: string[] = [] const junctionFields: string[] = []