From e41315fb72d30248e7f5b50e3d74db3af6dbaddb Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Mon, 4 Nov 2024 10:48:14 +0100 Subject: [PATCH] Fix --- .../src/utilities/rowProcessor/index.ts | 55 ++++++------------- 1 file changed, 18 insertions(+), 37 deletions(-) diff --git a/packages/server/src/utilities/rowProcessor/index.ts b/packages/server/src/utilities/rowProcessor/index.ts index 2217c0159f..907dcb1de4 100644 --- a/packages/server/src/utilities/rowProcessor/index.ts +++ b/packages/server/src/utilities/rowProcessor/index.ts @@ -420,6 +420,7 @@ export async function coreOutputProcessing( rows = await processFormulas(table, rows, { dynamic: true }) // remove null properties to match internal API + const isExternal = isExternalTableID(table._id!) for (const row of rows) { for (const key of Object.keys(row)) { if (row[key] === null) { @@ -434,54 +435,34 @@ export async function coreOutputProcessing( } } } - - if (sdk.views.isView(source)) { - // We ensure calculation fields are returned as numbers. During the - // testing of this feature it was discovered that the COUNT operation - // returns a string for MySQL, MariaDB, and Postgres. But given that all - // calculation fields (except ones operating on BIGINTs) should be - // numbers, we blanket make sure of that here. - for (const [name, field] of Object.entries( - helpers.views.calculationFields(source) - )) { - if ("field" in field) { - const targetSchema = table.schema[field.field] - // We don't convert BIGINT fields to floats because we could lose - // precision. - if (targetSchema.type === FieldType.BIGINT) { - continue - } - } - - for (const row of rows) { - if (typeof row[name] === "string") { - row[name] = parseFloat(row[name]) - } - } - } - } } if (sdk.views.isView(source)) { - const calculationFields = Object.keys( - helpers.views.calculationFields(source) - ) - - // We ensure all calculation fields are returned as numbers. During the + // We ensure calculation fields are returned as numbers. During the // testing of this feature it was discovered that the COUNT operation // returns a string for MySQL, MariaDB, and Postgres. But given that all - // calculation fields should be numbers, we blanket make sure of that - // here. - for (const key of calculationFields) { + // calculation fields (except ones operating on BIGINTs) should be + // numbers, we blanket make sure of that here. + for (const [name, field] of Object.entries( + helpers.views.calculationFields(source) + )) { + if ("field" in field) { + const targetSchema = table.schema[field.field] + // We don't convert BIGINT fields to floats because we could lose + // precision. + if (targetSchema.type === FieldType.BIGINT) { + continue + } + } + for (const row of rows) { - if (typeof row[key] === "string") { - row[key] = parseFloat(row[key]) + if (typeof row[name] === "string") { + row[name] = parseFloat(row[name]) } } } } - const isExternal = isExternalTableID(table._id!) if (!isUserMetadataTable(table._id!)) { const protectedColumns = isExternal ? PROTECTED_EXTERNAL_COLUMNS