1
0
Fork 0
mirror of synced 2024-09-09 22:16:26 +12:00

Fix patch

This commit is contained in:
Adria Navarro 2024-06-07 11:39:36 +02:00
parent 20d1b81099
commit 853810704c

View file

@ -56,13 +56,18 @@ export async function patch(ctx: UserCtx<PatchRowRequest, PatchRowResponse>) {
throw { validation: validateResult.errors } throw { validation: validateResult.errors }
} }
const beforeRow = await sdk.rows.external.getRow(tableId, _id, {
relationships: true,
})
const response = await handleRequest(Operation.UPDATE, tableId, { const response = await handleRequest(Operation.UPDATE, tableId, {
id: breakRowIdField(_id), id: breakRowIdField(_id),
row: dataToUpdate, row: dataToUpdate,
}) })
// The id might have been changed, so the refetching would fail. Recalculating the id just in case // The id might have been changed, so the refetching would fail. Recalculating the id just in case
const updatedId = generateIdForRow(ctx.request.body, table) const updatedId =
generateIdForRow({ ...beforeRow, ...dataToUpdate }, table) || _id
const row = await sdk.rows.external.getRow(tableId, updatedId, { const row = await sdk.rows.external.getRow(tableId, updatedId, {
relationships: true, relationships: true,
}) })