Merge pull request #14791 from Budibase/fix/inconsistent-column-schemas
Fixing inconsistent column schemas
This commit is contained in:
commit
490c4ae392
|
@ -23,6 +23,7 @@
|
|||
sourceType: DB_TYPE_EXTERNAL,
|
||||
schema: {
|
||||
id: {
|
||||
name: "id",
|
||||
autocolumn: true,
|
||||
type: "number",
|
||||
},
|
||||
|
|
|
@ -71,19 +71,20 @@ export async function fetch(ctx: UserCtx<void, FetchTablesResponse>) {
|
|||
|
||||
const datasources = await sdk.datasources.getExternalDatasources()
|
||||
|
||||
const external = datasources.flatMap(datasource => {
|
||||
const external: Table[] = []
|
||||
for (const datasource of datasources) {
|
||||
let entities = datasource.entities
|
||||
if (entities) {
|
||||
return Object.values(entities).map<Table>((entity: Table) => ({
|
||||
...entity,
|
||||
sourceType: TableSourceType.EXTERNAL,
|
||||
sourceId: datasource._id!,
|
||||
sql: isSQL(datasource),
|
||||
}))
|
||||
} else {
|
||||
return []
|
||||
for (const entity of Object.values(entities)) {
|
||||
external.push({
|
||||
...(await processTable(entity)),
|
||||
sourceType: TableSourceType.EXTERNAL,
|
||||
sourceId: datasource._id!,
|
||||
sql: isSQL(datasource),
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
const result: FetchTablesResponse = []
|
||||
for (const table of [...internal, ...external]) {
|
||||
|
|
|
@ -20,7 +20,13 @@ export async function processTable(table: Table): Promise<Table> {
|
|||
if (!table) {
|
||||
return table
|
||||
}
|
||||
|
||||
table = { ...table }
|
||||
if (table._id && isExternalTableID(table._id)) {
|
||||
// Old created external tables via Budibase might have a missing field name breaking some UI such as filters
|
||||
if (table.schema["id"] && !table.schema["id"].name) {
|
||||
table.schema["id"].name = "id"
|
||||
}
|
||||
return {
|
||||
...table,
|
||||
type: "table",
|
||||
|
|
Loading…
Reference in New Issue