Merge pull request #6563 from Budibase/bug/sev2/generate-select-statement-null-pointer-fix

Don't try to check externalType of related tables
This commit is contained in:
melohagan 2022-07-08 09:21:37 +01:00 committed by GitHub
commit 51013b9723
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 2 deletions

View File

@ -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}"`