Skip to content

Commit

Permalink
Allow "type" to be used as identifier in PostgreSQL
Browse files Browse the repository at this point in the history
Fixes #685
  • Loading branch information
nene committed Dec 7, 2023
1 parent 7e3db7f commit cd7ec6c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/languages/postgresql/postgresql.formatter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ const onelineClauses = expandPhrases([
'ADD [COLUMN] [IF NOT EXISTS]',
'DROP [COLUMN] [IF EXISTS]',
'ALTER [COLUMN]',
'[SET DATA] TYPE', // for alter column
'SET DATA TYPE', // for alter column
'{SET | DROP} DEFAULT', // for alter column
'{SET | DROP} NOT NULL', // for alter column
// - truncate:
Expand Down
11 changes: 11 additions & 0 deletions test/postgresql.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -301,4 +301,15 @@ describe('PostgreSqlFormatter', () => {
tbl.salary;
`);
});

// Issue #685
it('allows TYPE to be used as an identifier', () => {
expect(format(`SELECT type, modified_at FROM items;`)).toBe(dedent`
SELECT
type,
modified_at
FROM
items;
`);
});
});

0 comments on commit cd7ec6c

Please sign in to comment.