Fix wrong schema while fetching from datasource

This commit is contained in:
Adria Navarro 2024-10-14 13:20:34 +02:00
parent 61967b6b4b
commit 874df3f54d
1 changed files with 11 additions and 10 deletions

View File

@ -71,19 +71,20 @@ export async function fetch(ctx: UserCtx<void, FetchTablesResponse>) {
const datasources = await sdk.datasources.getExternalDatasources() const datasources = await sdk.datasources.getExternalDatasources()
const external = datasources.flatMap(datasource => { const external: Table[] = []
for (const datasource of datasources) {
let entities = datasource.entities let entities = datasource.entities
if (entities) { if (entities) {
return Object.values(entities).map<Table>((entity: Table) => ({ for (const entity of Object.values(entities)) {
...entity, external.push({
sourceType: TableSourceType.EXTERNAL, ...(await processTable(entity)),
sourceId: datasource._id!, sourceType: TableSourceType.EXTERNAL,
sql: isSQL(datasource), sourceId: datasource._id!,
})) sql: isSQL(datasource),
} else { })
return [] }
} }
}) }
const result: FetchTablesResponse = [] const result: FetchTablesResponse = []
for (const table of [...internal, ...external]) { for (const table of [...internal, ...external]) {