From 3c5d5f4c25ea45663edb2c26afc8ebf1bc6879c9 Mon Sep 17 00:00:00 2001 From: adrinr Date: Tue, 21 Feb 2023 09:42:56 +0000 Subject: [PATCH 1/2] Fix relation get test to test expected behaviour --- packages/server/src/integration-test/postgres.spec.ts | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/packages/server/src/integration-test/postgres.spec.ts b/packages/server/src/integration-test/postgres.spec.ts index ecfb532e7f..32d4204ea1 100644 --- a/packages/server/src/integration-test/postgres.spec.ts +++ b/packages/server/src/integration-test/postgres.spec.ts @@ -419,14 +419,16 @@ describe("row api - postgres", () => { describe("given a row with relation data", () => { let row: Row + let foreignRow: Row beforeEach(async () => { let [createdRow] = await populatePrimaryRows(1, { createForeignRow: true, }) row = createdRow.row + foreignRow = createdRow.foreignRow! }) - it("foreign key fields are not retrieved", async () => { + it("only foreign keys are retrieved", async () => { const res = await getRow(primaryPostgresTable._id, row.id) expect(res.status).toBe(200) @@ -436,7 +438,12 @@ describe("row api - postgres", () => { _id: expect.any(String), _rev: expect.any(String), }) - expect(res.body.foreignField).toBeUndefined() + expect( + res.body[`fk_${auxPostgresTable.name}_foreignField`] + ).toBeDefined() + expect(res.body[`fk_${auxPostgresTable.name}_foreignField`]).toBe( + foreignRow.id + ) }) }) }) From 483f15a5d6a08337d52c149d566c00fc4c1ef451 Mon Sep 17 00:00:00 2001 From: adrinr Date: Tue, 21 Feb 2023 09:51:07 +0000 Subject: [PATCH 2/2] Add explicit check for the foreign field --- packages/server/src/integration-test/postgres.spec.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/server/src/integration-test/postgres.spec.ts b/packages/server/src/integration-test/postgres.spec.ts index 32d4204ea1..c688600e8d 100644 --- a/packages/server/src/integration-test/postgres.spec.ts +++ b/packages/server/src/integration-test/postgres.spec.ts @@ -438,6 +438,9 @@ describe("row api - postgres", () => { _id: expect.any(String), _rev: expect.any(String), }) + + expect(res.body.foreignField).toBeUndefined() + expect( res.body[`fk_${auxPostgresTable.name}_foreignField`] ).toBeDefined()