From f26a8d410aef9e3994962843655f2a172f982273 Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Fri, 5 Jul 2024 11:19:01 +0200 Subject: [PATCH] Add export composite key --- .../server/src/api/routes/tests/row.spec.ts | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/packages/server/src/api/routes/tests/row.spec.ts b/packages/server/src/api/routes/tests/row.spec.ts index b6e3edf5ff..d92438a310 100644 --- a/packages/server/src/api/routes/tests/row.spec.ts +++ b/packages/server/src/api/routes/tests/row.spec.ts @@ -1452,6 +1452,43 @@ describe.each([ { status: 404 } ) }) + + it("can export rows with composite primary keys", async () => { + const tableRequest = saveTableRequest({ + primary: ["number", "string"], + schema: { + string: { + type: FieldType.STRING, + name: "string", + }, + number: { + type: FieldType.NUMBER, + name: "number", + }, + }, + }) + delete tableRequest.schema.id + + const table = await config.api.table.save(tableRequest) + + const rows = await Promise.all( + generator + .unique( + () => ({ + string: generator.word({ length: 30 }), + number: generator.integer({ min: 0, max: 10000 }), + }), + 10 + ) + .map(d => config.api.row.save(table._id!, d)) + ) + + const res = await config.api.row.exportRows(table._id!, { + rows: _.sampleSize(rows, 3).map(r => r._id!), + }) + const results = JSON.parse(res) + expect(results.length).toEqual(3) + }) }) let o2mTable: Table