Fix patch on external ds

This commit is contained in:
Adria Navarro 2023-09-27 15:34:22 +02:00
parent 81ca81222c
commit d0fcb5d7e6
2 changed files with 18 additions and 3 deletions

View File

@ -56,14 +56,21 @@ export async function patch(ctx: UserCtx<PatchRowRequest, PatchRowResponse>) {
if (!validateResult.valid) {
throw { validation: validateResult.errors }
}
const table = await sdk.tables.getTable(tableId)
const { row: dataToUpdate } = await inputProcessing(
ctx.user?._id,
cloneDeep(table),
rowData
)
const response = await handleRequest(Operation.UPDATE, tableId, {
id: breakRowIdField(_id),
row: rowData,
row: dataToUpdate,
})
const row = await sdk.rows.external.getRow(tableId, _id, {
relationships: true,
})
const table = await sdk.tables.getTable(tableId)
return {
...response,
row,
@ -107,9 +114,11 @@ export async function save(ctx: UserCtx) {
return {
...response,
row,
// row: await outputProcessing(table, row),
}
} else {
return response
// return outputProcessing(table, response)
}
}

View File

@ -1,6 +1,8 @@
import { IncludeRelationship, Operation, Row } from "@budibase/types"
import { handleRequest } from "../../../api/controllers/row/external"
import { breakRowIdField } from "../../../integrations/utils"
import { outputProcessing } from "../../../utilities/rowProcessor"
import sdk from "../../../sdk"
export async function getRow(
tableId: string,
@ -13,5 +15,9 @@ export async function getRow(
? IncludeRelationship.INCLUDE
: IncludeRelationship.EXCLUDE,
})) as Row[]
return response ? response[0] : response
const row = response ? response[0] : response
const table = await sdk.tables.getTable(tableId)
const enrichedRow = await outputProcessing(table, row)
return enrichedRow
}