Skip to content

Commit 73b5866

Browse files
committed
Properly detect PostgreSQL TEXT as data type
Fixes #726
1 parent 585bb8a commit 73b5866

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

src/languages/postgresql/postgresql.functions.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ export const functions: string[] = [
232232
'NETMASK',
233233
'NETWORK',
234234
'SET_MASKLEN',
235-
'TEXT',
235+
// 'TEXT', // excluded because it's also a data type name
236236
'TRUNC',
237237

238238
// https://www.postgresql.org/docs/14/functions-textsearch.html

test/postgresql.test.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,4 +345,23 @@ describe('PostgreSqlFormatter', () => {
345345
id;
346346
`);
347347
});
348+
349+
// Issue #726
350+
it('treats TEXT as data-type (not as plain keyword)', () => {
351+
expect(
352+
format(`CREATE TABLE foo (items text);`, {
353+
dataTypeCase: 'upper',
354+
})
355+
).toBe(dedent`
356+
CREATE TABLE foo (items TEXT);
357+
`);
358+
359+
expect(
360+
format(`CREATE TABLE foo (text VARCHAR(100));`, {
361+
keywordCase: 'upper',
362+
})
363+
).toBe(dedent`
364+
CREATE TABLE foo (text VARCHAR(100));
365+
`);
366+
});
348367
});

0 commit comments

Comments
 (0)