This commit is contained in:
Adria Navarro 2024-07-23 15:22:26 +02:00
parent 75609b2a9b
commit 4169842018
2 changed files with 7 additions and 3 deletions

View File

@ -57,7 +57,9 @@ export async function patch(ctx: UserCtx<PatchRowRequest, PatchRowResponse>) {
throw { validation: validateResult.errors }
}
const beforeRow = await sdk.rows.external.find(tableId, _id)
const beforeRow = await sdk.rows.external.getRow(tableId, _id, {
relationships: true,
})
const response = await handleRequest(Operation.UPDATE, tableId, {
id: breakRowIdField(_id),
@ -67,7 +69,9 @@ export async function patch(ctx: UserCtx<PatchRowRequest, PatchRowResponse>) {
// The id might have been changed, so the refetching would fail. Recalculating the id just in case
const updatedId =
generateIdForRow({ ...beforeRow, ...dataToUpdate }, table) || _id
const row = await sdk.rows.external.find(tableId, updatedId)
const row = await sdk.rows.external.getRow(tableId, updatedId, {
relationships: true,
})
const [enrichedRow, oldRow] = await Promise.all([
outputProcessing(table, row, {

View File

@ -9,7 +9,7 @@ import {
import cloneDeep from "lodash/fp/cloneDeep"
import isEqual from "lodash/fp/isEqual"
async function getRow(
export async function getRow(
tableId: string,
rowId: string,
opts?: { relationships?: boolean }