Merge pull request #8108 from Budibase/fix/6880

Minor fix for public API + SQL table rows
This commit is contained in:
Michael Drury 2022-10-04 10:33:08 +01:00 committed by GitHub
commit aee2b25d57
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 2 deletions

View File

@ -52,14 +52,19 @@ export async function read(ctx: any, next: any) {
} }
export async function update(ctx: any, next: any) { export async function update(ctx: any, next: any) {
ctx.request.body = await addRev(fixRow(ctx.request.body, ctx.params)) const { tableId } = ctx.params
ctx.request.body = await addRev(fixRow(ctx.request.body, ctx.params), tableId)
await rowController.save(ctx) await rowController.save(ctx)
await next() await next()
} }
export async function destroy(ctx: any, next: any) { export async function destroy(ctx: any, next: any) {
const { tableId } = ctx.params
// set the body as expected, with the _id and _rev fields // set the body as expected, with the _id and _rev fields
ctx.request.body = await addRev(fixRow({ _id: ctx.params.rowId }, ctx.params)) ctx.request.body = await addRev(
fixRow({ _id: ctx.params.rowId }, ctx.params),
tableId
)
await rowController.destroy(ctx) await rowController.destroy(ctx)
// destroy controller doesn't currently return the row as the body, need to adjust this // destroy controller doesn't currently return the row as the body, need to adjust this
// in the public API to be correct // in the public API to be correct