diff --git a/packages/server/src/integrations/base/sql.ts b/packages/server/src/integrations/base/sql.ts index 2758b6f1f1..fbbc42151a 100644 --- a/packages/server/src/integrations/base/sql.ts +++ b/packages/server/src/integrations/base/sql.ts @@ -99,8 +99,12 @@ function generateSelectStatement( const fieldNames = field.split(/\./g) const tableName = fieldNames[0] const columnName = fieldNames[1] - if (columnName && knex.client.config.client === SqlClients.POSTGRES) { - const externalType = schema?.[columnName].externalType + if ( + columnName && + schema?.[columnName] && + knex.client.config.client === SqlClients.POSTGRES + ) { + const externalType = schema[columnName].externalType if (externalType?.includes("money")) { return knex.raw( `"${tableName}"."${columnName}"::money::numeric as "${field}"`