From e928ff2ea25d4020e3fc25690754d2c3cdc898fb Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Thu, 9 May 2024 15:26:53 +0100 Subject: [PATCH] Adding test case to confirm it works. --- .../src/integration-test/postgres.spec.ts | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/packages/server/src/integration-test/postgres.spec.ts b/packages/server/src/integration-test/postgres.spec.ts index cf80f2359f..ec4cb90a86 100644 --- a/packages/server/src/integration-test/postgres.spec.ts +++ b/packages/server/src/integration-test/postgres.spec.ts @@ -1200,4 +1200,38 @@ describe("postgres integrations", () => { expect(Object.keys(schema).sort()).toEqual(["id", "val1"]) }) }) + + describe("check custom column types", () => { + beforeAll(async () => { + await rawQuery( + rawDatasource, + `CREATE TABLE binaryTable ( + id BYTEA PRIMARY KEY, + column1 TEXT, + column2 INT + ); + ` + ) + }) + + it("should handle binary columns", async () => { + const response = await makeRequest( + "post", + `/api/datasources/${datasource._id}/schema` + ) + expect(response.body).toBeDefined() + expect(response.body.datasource.entities).toBeDefined() + const table = response.body.datasource.entities["binarytable"] + expect(table).toBeDefined() + expect(table.schema.id.externalType).toBe("bytea") + const row = await config.api.row.save(table._id, { + id: "1111", + column1: "hello", + column2: 222, + }) + expect(row._id).toBeDefined() + const decoded = decodeURIComponent(row._id!).replace(/'/g, '"') + expect(JSON.parse(decoded)[0]).toBe("1111") + }) + }) })