From a4123b5ecd7d6f621d0524ff0b974410e9839181 Mon Sep 17 00:00:00 2001 From: Florent Cailhol Date: Fri, 22 Nov 2024 11:52:34 +0100 Subject: [PATCH] Test function calls as default value for PostgreSQL In specific case, `drizzle-kit pull` is not able to generate a valid schema. This test checks if drizzle is able to generate the default value for `md5('str')`. --- drizzle-kit/tests/introspect/pg.test.ts | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/drizzle-kit/tests/introspect/pg.test.ts b/drizzle-kit/tests/introspect/pg.test.ts index 1d9f0f18c..1c44f6316 100644 --- a/drizzle-kit/tests/introspect/pg.test.ts +++ b/drizzle-kit/tests/introspect/pg.test.ts @@ -892,3 +892,22 @@ test('multiple policies with roles from schema', async () => { expect(statements.length).toBe(0); expect(sqlStatements.length).toBe(0); }); + +test('default-function-call', async () => { + const client = new PGlite(); + + const schema = { + foo: pgTable('foo', { + bar: text('bar').default(sql`md5('baz')`), + }), + }; + + const { statements, sqlStatements } = await introspectPgToFile( + client, + schema, + 'default-functions-call', + ); + + expect(statements.length).toBe(0); + expect(sqlStatements.length).toBe(0); +});