Fix issues with display names not being sql tables
This commit is contained in:
parent
bcc9bba254
commit
b05b523a6e
|
@ -119,13 +119,14 @@ export async function buildSqlFieldList(
|
||||||
opts?: { relationships: boolean }
|
opts?: { relationships: boolean }
|
||||||
) {
|
) {
|
||||||
const { relationships } = opts || {}
|
const { relationships } = opts || {}
|
||||||
|
|
||||||
|
const nonMappedColumns = [FieldType.LINK, FieldType.FORMULA, FieldType.AI]
|
||||||
|
|
||||||
function extractRealFields(table: Table, existing: string[] = []) {
|
function extractRealFields(table: Table, existing: string[] = []) {
|
||||||
return Object.entries(table.schema)
|
return Object.entries(table.schema)
|
||||||
.filter(
|
.filter(
|
||||||
([columnName, column]) =>
|
([columnName, column]) =>
|
||||||
column.type !== FieldType.LINK &&
|
!nonMappedColumns.includes(column.type) &&
|
||||||
column.type !== FieldType.FORMULA &&
|
|
||||||
column.type !== FieldType.AI &&
|
|
||||||
!existing.find((field: string) => field === columnName)
|
!existing.find((field: string) => field === columnName)
|
||||||
)
|
)
|
||||||
.map(([columnName]) => columnName)
|
.map(([columnName]) => columnName)
|
||||||
|
@ -145,7 +146,10 @@ export async function buildSqlFieldList(
|
||||||
}
|
}
|
||||||
|
|
||||||
return requiredFields.filter(
|
return requiredFields.filter(
|
||||||
column => !existing.find((field: string) => field === column)
|
column =>
|
||||||
|
!existing.find((field: string) => field === column) &&
|
||||||
|
table.schema[column] &&
|
||||||
|
!nonMappedColumns.includes(table.schema[column].type)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -231,6 +235,7 @@ export async function buildSqlFieldList(
|
||||||
}
|
}
|
||||||
|
|
||||||
const fieldsToAdd = Array.from(viewFields)
|
const fieldsToAdd = Array.from(viewFields)
|
||||||
|
.filter(f => !nonMappedColumns.includes(relatedTable.schema[f].type))
|
||||||
.map(f => `${relatedTable.name}.${f}`)
|
.map(f => `${relatedTable.name}.${f}`)
|
||||||
.filter(f => !fields.includes(f))
|
.filter(f => !fields.includes(f))
|
||||||
fields.push(...fieldsToAdd)
|
fields.push(...fieldsToAdd)
|
||||||
|
|
Loading…
Reference in New Issue