Skip to content

Commit

Permalink
Add support for Postgresql JSON and JSONB data types
Browse files Browse the repository at this point in the history
  • Loading branch information
forsstromerik committed Feb 21, 2025
1 parent 93a423b commit ca16761
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/languages/postgresql/postgresql.keywords.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
8 changes: 8 additions & 0 deletions test/postgresql.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);');
});
});

0 comments on commit ca16761

Please sign in to comment.