diff --git a/packages/server/src/sdk/app/tables/getters.ts b/packages/server/src/sdk/app/tables/getters.ts index 80524a0413..02cef748c5 100644 --- a/packages/server/src/sdk/app/tables/getters.ts +++ b/packages/server/src/sdk/app/tables/getters.ts @@ -117,7 +117,7 @@ export function enrichViewSchemas(table: Table): TableResponse { views: Object.values(table.views ?? []) .map(v => sdk.views.enrichSchema(v, table.schema)) .reduce((p, v) => { - p[v.name] = v + p[v.name!] = v return p }, {} as TableViewsResponse), } diff --git a/packages/server/src/sdk/app/views/external.ts b/packages/server/src/sdk/app/views/external.ts index bc240ae17b..47301873f5 100644 --- a/packages/server/src/sdk/app/views/external.ts +++ b/packages/server/src/sdk/app/views/external.ts @@ -59,11 +59,10 @@ export async function update(tableId: string, view: ViewV2): Promise { const existingView = Object.values(views).find( v => isV2(v) && v.id === view.id ) - if (!existingView) { + if (!existingView || !existingView.name) { throw new HTTPError(`View ${view.id} not found in table ${tableId}`, 404) } - console.log("set to", view) delete views[existingView.name] views[view.name] = view await db.put(ds) diff --git a/packages/server/src/sdk/app/views/internal.ts b/packages/server/src/sdk/app/views/internal.ts index 97b47fbcb5..d1dedd8566 100644 --- a/packages/server/src/sdk/app/views/internal.ts +++ b/packages/server/src/sdk/app/views/internal.ts @@ -51,11 +51,10 @@ export async function update(tableId: string, view: ViewV2): Promise { const existingView = Object.values(table.views).find( v => isV2(v) && v.id === view.id ) - if (!existingView) { + if (!existingView || !existingView.name) { throw new HTTPError(`View ${view.id} not found in table ${tableId}`, 404) } - console.log("set to", view) delete table.views[existingView.name] table.views[view.name] = view await db.put(table)