From d34557bc97fd2f6be3ad8131a99ec45da296da22 Mon Sep 17 00:00:00 2001 From: Rene Saarsoo Date: Thu, 7 Dec 2023 14:01:44 +0200 Subject: [PATCH] Remove some common table/field names from PostgreSQL keywords Fixes #156 --- src/languages/postgresql/postgresql.keywords.ts | 7 ------- test/postgresql.test.ts | 15 +++++++++++++++ 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/src/languages/postgresql/postgresql.keywords.ts b/src/languages/postgresql/postgresql.keywords.ts index d00cfae0e0..ca6ede1ac9 100644 --- a/src/languages/postgresql/postgresql.keywords.ts +++ b/src/languages/postgresql/postgresql.keywords.ts @@ -191,7 +191,6 @@ export const keywords: string[] = [ 'ISOLATION', 'JOIN', // reserved (can be function or type) 'KEY', - 'LABEL', 'LANGUAGE', 'LARGE', 'LAST', @@ -208,7 +207,6 @@ export const keywords: string[] = [ 'LOCAL', 'LOCALTIME', // reserved 'LOCALTIMESTAMP', // reserved - 'LOCATION', 'LOCK', 'LOCKED', 'LOGGED', @@ -222,8 +220,6 @@ export const keywords: string[] = [ 'MODE', 'MONTH', // requires AS 'MOVE', - 'NAME', - 'NAMES', 'NATIONAL', // (cannot be function or type) 'NATURAL', // reserved (can be function or type) 'NCHAR', // (cannot be function or type) @@ -302,7 +298,6 @@ export const keywords: string[] = [ 'REFRESH', 'REINDEX', 'RELATIVE', - 'RELEASE', 'RENAME', 'REPEATABLE', 'REPLACE', @@ -384,8 +379,6 @@ export const keywords: string[] = [ 'TRUE', // reserved 'TRUNCATE', 'TRUSTED', - 'TYPE', - 'TYPES', 'UESCAPE', 'UNBOUNDED', 'UNCOMMITTED', diff --git a/test/postgresql.test.ts b/test/postgresql.test.ts index d7d985b6ae..6f68906c94 100644 --- a/test/postgresql.test.ts +++ b/test/postgresql.test.ts @@ -312,4 +312,19 @@ describe('PostgreSqlFormatter', () => { items; `); }); + + // Issue #156 + it('does not recognize common fields names as keywords', () => { + expect(format(`SELECT id, type, name, location, label FROM release;`, { keywordCase: 'upper' })) + .toBe(dedent` + SELECT + id, + type, + name, + location, + label + FROM + release; + `); + }); });