Handle view schemas on external

This commit is contained in:
Adria Navarro 2023-08-09 14:00:18 +03:00
parent 1b9784013c
commit a17f81ffb3
1 changed files with 11 additions and 0 deletions

View File

@ -27,6 +27,7 @@ import {
Table,
TableRequest,
UserCtx,
ViewV2,
} from "@budibase/types"
import sdk from "../../../sdk"
import { builderSocket } from "../../../websockets"
@ -226,6 +227,16 @@ export async function save(ctx: UserCtx<SaveTableRequest, SaveTableResponse>) {
ctx.throw(400, "A column type has changed.")
}
for (let view in tableToSave.views) {
const tableView = tableToSave.views[view]
if (!tableView || !sdk.views.isV2(tableView)) continue
tableToSave.views[view] = sdk.views.syncSchema(
oldTable!.views![view] as ViewV2,
tableToSave.schema
)
}
const db = context.getAppDB()
const datasource = await sdk.datasources.get(datasourceId)
if (!datasource.entities) {