From d0fcb5d7e686494abbb168f36915d9f6baec0ea8 Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Wed, 27 Sep 2023 15:34:22 +0200 Subject: [PATCH] Fix patch on external ds --- packages/server/src/api/controllers/row/external.ts | 13 +++++++++++-- packages/server/src/sdk/app/rows/external.ts | 8 +++++++- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/packages/server/src/api/controllers/row/external.ts b/packages/server/src/api/controllers/row/external.ts index a16892296d..ec9a3e8fb0 100644 --- a/packages/server/src/api/controllers/row/external.ts +++ b/packages/server/src/api/controllers/row/external.ts @@ -56,14 +56,21 @@ export async function patch(ctx: UserCtx) { 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) } } diff --git a/packages/server/src/sdk/app/rows/external.ts b/packages/server/src/sdk/app/rows/external.ts index 568bd07e9d..6652be3a89 100644 --- a/packages/server/src/sdk/app/rows/external.ts +++ b/packages/server/src/sdk/app/rows/external.ts @@ -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 }