Skip to content

Commit

Permalink
Properly detect PostgreSQL TEXT as data type
Browse files Browse the repository at this point in the history
Fixes #726
  • Loading branch information
nene committed Mar 16, 2024
1 parent 585bb8a commit 73b5866
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/languages/postgresql/postgresql.functions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ export const functions: string[] = [
'NETMASK',
'NETWORK',
'SET_MASKLEN',
'TEXT',
// 'TEXT', // excluded because it's also a data type name
'TRUNC',

// https://www.postgresql.org/docs/14/functions-textsearch.html
Expand Down
19 changes: 19 additions & 0 deletions test/postgresql.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -345,4 +345,23 @@ describe('PostgreSqlFormatter', () => {
id;
`);
});

// Issue #726
it('treats TEXT as data-type (not as plain keyword)', () => {
expect(
format(`CREATE TABLE foo (items text);`, {
dataTypeCase: 'upper',
})
).toBe(dedent`
CREATE TABLE foo (items TEXT);
`);

expect(
format(`CREATE TABLE foo (text VARCHAR(100));`, {
keywordCase: 'upper',
})
).toBe(dedent`
CREATE TABLE foo (text VARCHAR(100));
`);
});
});

0 comments on commit 73b5866

Please sign in to comment.