From b975132329993510a6e08ef24d3e035b38d11eb3 Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Thu, 7 Mar 2024 18:08:50 +0000 Subject: [PATCH 1/3] Fix for deleted row issue - test incoming. --- packages/server/src/api/controllers/row/external.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/server/src/api/controllers/row/external.ts b/packages/server/src/api/controllers/row/external.ts index dc3b556c54..8ce9ff0f9d 100644 --- a/packages/server/src/api/controllers/row/external.ts +++ b/packages/server/src/api/controllers/row/external.ts @@ -128,7 +128,10 @@ export async function bulkDestroy(ctx: UserCtx) { ) } const responses = await Promise.all(promises) - return { response: { ok: true }, rows: responses.map(resp => resp.row) } + const finalRows = responses + .map(resp => resp.row) + .filter(row => row && row._id) + return { response: { ok: true }, rows: finalRows } } export async function fetchEnrichedRow(ctx: UserCtx) { From 9ec77c45c8c9334db977c9f2ca0652231198fea2 Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Fri, 8 Mar 2024 10:24:48 +0000 Subject: [PATCH 2/3] Adding test case to confirm works as expected. --- packages/server/src/api/controllers/public/utils.ts | 3 ++- packages/server/src/api/controllers/row/index.ts | 5 ++++- packages/server/src/api/routes/tests/row.spec.ts | 11 +++++++++++ 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/packages/server/src/api/controllers/public/utils.ts b/packages/server/src/api/controllers/public/utils.ts index 1d67b49e0d..ec1d7cfa47 100644 --- a/packages/server/src/api/controllers/public/utils.ts +++ b/packages/server/src/api/controllers/public/utils.ts @@ -1,11 +1,12 @@ import { context } from "@budibase/backend-core" import { isExternalTableID } from "../../../integrations/utils" import { APP_PREFIX, DocumentType } from "../../../db/utils" +import { Row } from "@budibase/types" export async function addRev( body: { _id?: string; _rev?: string }, tableId?: string -) { +): Promise { if (!body._id || (tableId && isExternalTableID(tableId))) { return body } diff --git a/packages/server/src/api/controllers/row/index.ts b/packages/server/src/api/controllers/row/index.ts index 54c294c42b..3466a4491d 100644 --- a/packages/server/src/api/controllers/row/index.ts +++ b/packages/server/src/api/controllers/row/index.ts @@ -131,7 +131,10 @@ async function processDeleteRowsRequest(ctx: UserCtx) { : fixRow(processedRow, ctx.params) }) - return await Promise.all(processedRows) + const responses = await Promise.allSettled(processedRows) + return responses + .filter(resp => resp.status === "fulfilled") + .map(resp => (resp as PromiseFulfilledResult).value) } async function deleteRows(ctx: UserCtx) { diff --git a/packages/server/src/api/routes/tests/row.spec.ts b/packages/server/src/api/routes/tests/row.spec.ts index de411f5397..a032f4324c 100644 --- a/packages/server/src/api/routes/tests/row.spec.ts +++ b/packages/server/src/api/routes/tests/row.spec.ts @@ -636,6 +636,17 @@ describe.each([ expect(res[0]._id).toEqual(createdRow._id) await assertRowUsage(rowUsage - 1) }) + + it("should be able to bulk delete rows, including a row that doesn't exist", async () => { + const createdRow = await config.createRow() + + const res = await config.api.row.bulkDelete(table._id!, { + rows: [createdRow, { _id: "2" }], + }) + + expect(res[0]._id).toEqual(createdRow._id) + expect(res.length).toEqual(1) + }) }) describe("validate", () => { From 7e3d6019be19c5d51fc113e368d07f4816c957a0 Mon Sep 17 00:00:00 2001 From: Budibase Staging Release Bot <> Date: Fri, 8 Mar 2024 15:35:42 +0000 Subject: [PATCH 3/3] Bump version to 2.21.5 --- lerna.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lerna.json b/lerna.json index a50794e91e..05cdc1532f 100644 --- a/lerna.json +++ b/lerna.json @@ -1,5 +1,5 @@ { - "version": "2.21.4", + "version": "2.21.5", "npmClient": "yarn", "packages": [ "packages/*",