diff --git a/src/languages/postgresql/postgresql.keywords.ts b/src/languages/postgresql/postgresql.keywords.ts index 91a54c9f8..4b7cf8be6 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 92967a4a4..cd4f9a9e5 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);'); + }); });