Making table required.

This commit is contained in:
Michael Drury 2024-04-16 17:22:17 +01:00
parent ccb56c8788
commit 8b0fc5ed5d
5 changed files with 12 additions and 3 deletions

View File

@ -437,7 +437,7 @@ export class ExternalRequest<T extends Operation> {
// if we're creating (in a through table) need to wipe the existing ones first // if we're creating (in a through table) need to wipe the existing ones first
const promises = [] const promises = []
const related = await this.lookupRelations(mainTableId, row) const related = await this.lookupRelations(mainTableId, row)
const table = this.getTable(mainTableId) const table = this.getTable(mainTableId)!
for (let relationship of relationships) { for (let relationship of relationships) {
const { key, tableId, isUpdate, id, ...rest } = relationship const { key, tableId, isUpdate, id, ...rest } = relationship
const body: { [key: string]: any } = processObjectSync(rest, row, {}) const body: { [key: string]: any } = processObjectSync(rest, row, {})

View File

@ -22,6 +22,7 @@ export async function makeTableRequest(
operation, operation,
}, },
meta: { meta: {
table,
tables, tables,
}, },
table, table,

View File

@ -756,7 +756,7 @@ describe.each(
}, },
}, },
meta: { meta: {
table: config.table, table: config.table!,
}, },
}) })
expect(res).toHaveLength(1) expect(res).toHaveLength(1)

View File

@ -66,7 +66,15 @@ function generateUpdateJson({
body = {}, body = {},
filters = {}, filters = {},
meta = {}, meta = {},
}: {
table: string
body?: any
filters?: any
meta?: any
}): QueryJson { }): QueryJson {
if (!meta.table) {
meta.table = table
}
return { return {
endpoint: endpoint(table, "UPDATE"), endpoint: endpoint(table, "UPDATE"),
filters, filters,

View File

@ -91,7 +91,7 @@ export interface QueryJson {
body?: Row | Row[] body?: Row | Row[]
table?: Table table?: Table
meta: { meta: {
table?: Table table: Table
tables?: Record<string, Table> tables?: Record<string, Table>
renamed?: RenameColumn renamed?: RenameColumn
} }