Skip to content

Commit ca16761

Browse files
committed
Add support for Postgresql JSON and JSONB data types
1 parent 93a423b commit ca16761

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

src/languages/postgresql/postgresql.keywords.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,8 @@ export const dataTypes: string[] = [
139139
'INTERVAL', // (cannot be function or type)
140140
'NCHAR', // (cannot be function or type)
141141
'NUMERIC', // (cannot be function or type)
142+
'JSON',
143+
'JSONB',
142144
'PRECISION', // (cannot be function or type), requires AS
143145
'REAL', // (cannot be function or type)
144146
'SMALLINT', // (cannot be function or type)

test/postgresql.test.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -390,4 +390,12 @@ describe('PostgreSqlFormatter', () => {
390390
CREATE OR REPLACE FUNCTION foo ();
391391
`);
392392
});
393+
394+
it('formats JSON and JSONB data types', () => {
395+
expect(
396+
format(`CREATE TABLE foo (bar json, baz jsonb);`, {
397+
dataTypeCase: 'upper',
398+
})
399+
).toBe('CREATE TABLE foo (bar JSON, baz JSONB);');
400+
});
393401
});

0 commit comments

Comments
 (0)