1
0
Fork 0
mirror of synced 2024-10-02 10:08:09 +13:00

Merge branch 'master' into feat/BUDI-8046

This commit is contained in:
Adria Navarro 2024-03-11 10:34:01 +01:00 committed by GitHub
commit 5e23205e15
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 22 additions and 4 deletions

View file

@ -1,5 +1,5 @@
{
"version": "2.21.4",
"version": "2.21.5",
"npmClient": "yarn",
"packages": [
"packages/*",

View file

@ -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<Row> {
if (!body._id || (tableId && isExternalTableID(tableId))) {
return body
}

View file

@ -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) {

View file

@ -131,7 +131,10 @@ async function processDeleteRowsRequest(ctx: UserCtx<DeleteRowRequest>) {
: 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<Row>).value)
}
async function deleteRows(ctx: UserCtx<DeleteRowRequest>) {

View file

@ -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", () => {