From ca167616bb8350197937f1f050d714a54d86c5ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Erik=20Forsstr=C3=B6m?= Date: Fri, 21 Feb 2025 14:57:58 +0100 Subject: [PATCH] Add support for Postgresql JSON and JSONB data types --- src/languages/postgresql/postgresql.keywords.ts | 2 ++ test/postgresql.test.ts | 8 ++++++++ 2 files changed, 10 insertions(+) diff --git a/src/languages/postgresql/postgresql.keywords.ts b/src/languages/postgresql/postgresql.keywords.ts index 91a54c9f85..4b7cf8be63 100644 --- a/src/languages/postgresql/postgresql.keywords.ts +++ b/src/languages/postgresql/postgresql.keywords.ts @@ -139,6 +139,8 @@ export const dataTypes: string[] = [ 'INTERVAL', // (cannot be function or type) 'NCHAR', // (cannot be function or type) 'NUMERIC', // (cannot be function or type) + 'JSON', + 'JSONB', 'PRECISION', // (cannot be function or type), requires AS 'REAL', // (cannot be function or type) 'SMALLINT', // (cannot be function or type) diff --git a/test/postgresql.test.ts b/test/postgresql.test.ts index 92967a4a41..cd4f9a9e5f 100644 --- a/test/postgresql.test.ts +++ b/test/postgresql.test.ts @@ -390,4 +390,12 @@ describe('PostgreSqlFormatter', () => { CREATE OR REPLACE FUNCTION foo (); `); }); + + it('formats JSON and JSONB data types', () => { + expect( + format(`CREATE TABLE foo (bar json, baz jsonb);`, { + dataTypeCase: 'upper', + }) + ).toBe('CREATE TABLE foo (bar JSON, baz JSONB);'); + }); });