Skip to content

Commit 2e5d224

Browse files
committed
Support UUID type and functions in PostgreSQL
Fixes #876
1 parent 8ba4d34 commit 2e5d224

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

src/languages/postgresql/postgresql.functions.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ export const functions: string[] = [
265265
'WEBSEARCH_TO_TSQUERY',
266266

267267
// https://www.postgresql.org/docs/14/functions-uuid.html
268-
'UUID',
268+
'GEN_RANDOM_UUID',
269269

270270
// https://www.postgresql.org/docs/14/functions-xml.html
271271
'CURSOR_TO_XML',

src/languages/postgresql/postgresql.keywords.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@ export const dataTypes: string[] = [
148148
'TIME', // (cannot be function or type)
149149
'TIMESTAMP', // (cannot be function or type)
150150
'TIMESTAMPTZ', // (cannot be function or type)
151+
'UUID',
151152
'VARCHAR', // (cannot be function or type)
152153
'XML',
153154
'ZONE',

test/postgresql.test.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,4 +230,14 @@ describe('PostgreSqlFormatter', () => {
230230
dedent`CREATE OR REPLACE PROCEDURE foo () LANGUAGE sql AS $$ BEGIN END $$;`
231231
);
232232
});
233+
234+
// Issue #876
235+
it('supports UUID type and functions', () => {
236+
expect(
237+
format(`CREATE TABLE foo (id uuid DEFAULT Gen_Random_Uuid());`, {
238+
dataTypeCase: 'upper',
239+
functionCase: 'lower',
240+
})
241+
).toBe(dedent`CREATE TABLE foo (id UUID DEFAULT gen_random_uuid());`);
242+
});
233243
});

0 commit comments

Comments
 (0)