From 5a3ecc3095e28dc99c1412ed1a946a5a5875ec02 Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Fri, 29 Sep 2023 13:40:40 +0100 Subject: [PATCH] Getting create/update response consistent with internal API for external. --- packages/server/src/api/routes/tests/row.spec.ts | 9 ++------- packages/server/src/utilities/rowProcessor/index.ts | 8 ++++++++ 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/packages/server/src/api/routes/tests/row.spec.ts b/packages/server/src/api/routes/tests/row.spec.ts index ec502f17bb..e6f70fc617 100644 --- a/packages/server/src/api/routes/tests/row.spec.ts +++ b/packages/server/src/api/routes/tests/row.spec.ts @@ -1787,19 +1787,14 @@ describe.each([ user: null, users: null, }) - const toCompare: any = { + expect(updatedRow).toEqual({ name: rowData.name, description: rowData.description, tableId, _id: row._id, _rev: expect.any(String), type: "row", - } - if (!isInternal) { - toCompare.user = null - toCompare.users = null - } - expect(updatedRow).toEqual(toCompare) + }) }) it("fetch all will populate the relationships", async () => { diff --git a/packages/server/src/utilities/rowProcessor/index.ts b/packages/server/src/utilities/rowProcessor/index.ts index 773b54dd6a..cf7cb0932b 100644 --- a/packages/server/src/utilities/rowProcessor/index.ts +++ b/packages/server/src/utilities/rowProcessor/index.ts @@ -250,6 +250,14 @@ export async function outputProcessing( enriched )) as Row[] } + // remove null properties to match internal API + for (let row of enriched) { + for (let key of Object.keys(row)) { + if (row[key] === null) { + delete row[key] + } + } + } return (wasArray ? enriched : enriched[0]) as T }