Skip to content

Commit 10b4451

Browse files
committed
Move more data types to separate constant
1 parent 2ba9d0a commit 10b4451

27 files changed

+284
-203
lines changed

src/languages/bigquery/bigquery.formatter.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -163,9 +163,8 @@ export const bigquery: DialectOptions = {
163163
reservedSetOperations,
164164
reservedJoins,
165165
reservedPhrases,
166-
reservedKeywords:
167-
// Temporary, will be replaced by reservedDataTypes
168-
[...new Set(keywords.concat(dataTypes))],
166+
reservedKeywords: keywords,
167+
reservedDataTypes: dataTypes,
169168
reservedFunctionNames: functions,
170169
extraParens: ['[]'],
171170
stringTypes: [

src/languages/bigquery/bigquery.keywords.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ export const keywords: string[] = [
33
'ALL',
44
'AND',
55
'ANY',
6-
'ARRAY',
76
'AS',
87
'ASC',
98
'ASSERT_ROWS_MODIFIED',
@@ -80,7 +79,6 @@ export const keywords: string[] = [
8079
'SELECT',
8180
'SET',
8281
'SOME',
83-
'STRUCT',
8482
'TABLE',
8583
'TABLESAMPLE',
8684
'THEN',

src/languages/db2i/db2i.formatter.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { DialectOptions } from '../../dialect.js';
22
import { expandPhrases } from '../../expandPhrases.js';
33
import { functions } from './db2i.functions.js';
4-
import { keywords } from './db2i.keywords.js';
4+
import { dataTypes, keywords } from './db2i.keywords.js';
55

66
const reservedSelect = expandPhrases(['SELECT [ALL | DISTINCT]']);
77

@@ -162,6 +162,7 @@ export const db2i: DialectOptions = {
162162
reservedJoins,
163163
reservedPhrases,
164164
reservedKeywords: keywords,
165+
reservedDataTypes: dataTypes,
165166
reservedFunctionNames: functions,
166167
nestedBlockComments: true,
167168
extraParens: ['[]'],

src/languages/db2i/db2i.keywords.ts

Lines changed: 34 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,7 @@ export const keywords: string[] = [
3232
'BEFORE',
3333
'BEGIN',
3434
'BETWEEN',
35-
'BINARY',
3635
'BIND',
37-
'BIT',
38-
'BOOLEAN',
3936
'BSON',
4037
'BUFFERPOOL',
4138
'BY',
@@ -45,9 +42,6 @@ export const keywords: string[] = [
4542
'CARDINALITY',
4643
'CASE',
4744
'CAST',
48-
'CCSID',
49-
'CHAR',
50-
'CHARACTER',
5145
'CHECK',
5246
'CL',
5347
'CLOSE',
@@ -90,11 +84,9 @@ export const keywords: string[] = [
9084
'CURRENT_USER',
9185
'CURSOR',
9286
'CYCLE',
93-
'DATA',
9487
'DATABASE',
9588
'DATAPARTITIONNAME',
9689
'DATAPARTITIONNUM',
97-
'DATE',
9890
'DAY',
9991
'DAYS',
10092
'DB2GENERAL',
@@ -127,7 +119,6 @@ export const keywords: string[] = [
127119
'DISTINCT',
128120
'DO',
129121
'DOCUMENT',
130-
'DOUBLE',
131122
'DROP',
132123
'DYNAMIC',
133124
'EACH',
@@ -177,7 +168,6 @@ export const keywords: string[] = [
177168
'GO',
178169
'GOTO',
179170
'GRANT',
180-
'GRAPHIC',
181171
'GROUP',
182172
'HANDLER',
183173
'HASH',
@@ -256,7 +246,6 @@ export const keywords: string[] = [
256246
'LOCKSIZE',
257247
'LOG',
258248
'LOGGED',
259-
'LONG',
260249
'LOOP',
261250
'MAINTAINED',
262251
'MASK',
@@ -436,8 +425,6 @@ export const keywords: string[] = [
436425
'TAG',
437426
'THEN',
438427
'THREADSAFE',
439-
'TIME',
440-
'TIMESTAMP',
441428
'TO',
442429
'TRANSACTION',
443430
'TRANSFER',
@@ -508,3 +495,37 @@ export const keywords: string[] = [
508495
'YES',
509496
'ZONE',
510497
];
498+
499+
export const dataTypes: string[] = [
500+
// https://www.ibm.com/docs/en/i/7.2?topic=iaodsd-odbc-data-types-how-they-correspond-db2-i-database-types
501+
'BIGINT',
502+
'BINARY',
503+
'BIT',
504+
'BLOB',
505+
'BOOLEAN',
506+
'CCSID',
507+
'CHAR',
508+
'CHARACTER',
509+
'CLOB',
510+
'DATA',
511+
'DATALINK',
512+
'DATE',
513+
'DBCLOB',
514+
'DECFLOAT',
515+
'DECIMAL',
516+
'DOUBLE',
517+
'FLOAT',
518+
'GRAPHIC',
519+
'INTEGER',
520+
'LONG',
521+
'NUMERIC',
522+
'REAL',
523+
'ROWID',
524+
'SMALLINT',
525+
'TIME',
526+
'TIMESTAMP',
527+
'VARBINARY',
528+
'VARCHAR',
529+
'VARGRAPHIC',
530+
'XML',
531+
];

src/languages/hive/hive.formatter.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { DialectOptions } from '../../dialect.js';
22
import { expandPhrases } from '../../expandPhrases.js';
33
import { functions } from './hive.functions.js';
4-
import { keywords } from './hive.keywords.js';
4+
import { dataTypes, keywords } from './hive.keywords.js';
55

66
const reservedSelect = expandPhrases(['SELECT [ALL | DISTINCT]']);
77

@@ -91,6 +91,7 @@ export const hive: DialectOptions = {
9191
reservedJoins,
9292
reservedPhrases,
9393
reservedKeywords: keywords,
94+
reservedDataTypes: dataTypes,
9495
reservedFunctionNames: functions,
9596
extraParens: ['[]'],
9697
stringTypes: ['""-bs', "''-bs"],

src/languages/hive/hive.keywords.ts

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,6 @@ export const keywords: string[] = [
126126
'STORED',
127127
'STREAMTABLE',
128128
'STRING',
129-
'STRUCT',
130129
'TABLES',
131130
'TBLPROPERTIES',
132131
'TEMPORARY',
@@ -186,18 +185,13 @@ export const keywords: string[] = [
186185
'ALL',
187186
'ALTER',
188187
'AND',
189-
'ARRAY',
190188
'AS',
191189
'AUTHORIZATION',
192190
'BETWEEN',
193-
'BIGINT',
194-
'BINARY',
195-
'BOOLEAN',
196191
'BOTH',
197192
'BY',
198193
'CASE',
199194
'CAST',
200-
'CHAR',
201195
'COLUMN',
202196
'CONF',
203197
'CREATE',
@@ -208,12 +202,9 @@ export const keywords: string[] = [
208202
'CURRENT_TIMESTAMP',
209203
'CURSOR',
210204
'DATABASE',
211-
'DATE',
212-
'DECIMAL',
213205
'DELETE',
214206
'DESCRIBE',
215207
'DISTINCT',
216-
'DOUBLE',
217208
'DROP',
218209
'ELSE',
219210
'END',
@@ -223,7 +214,6 @@ export const keywords: string[] = [
223214
'EXTERNAL',
224215
'FALSE',
225216
'FETCH',
226-
'FLOAT',
227217
'FOLLOWING',
228218
'FOR',
229219
'FROM',
@@ -238,9 +228,7 @@ export const keywords: string[] = [
238228
'IN',
239229
'INNER',
240230
'INSERT',
241-
'INT',
242231
'INTERSECT',
243-
'INTERVAL',
244232
'INTO',
245233
'IS',
246234
'JOIN',
@@ -250,7 +238,6 @@ export const keywords: string[] = [
250238
'LIKE',
251239
'LOCAL',
252240
'MACRO',
253-
'MAP',
254241
'MORE',
255242
'NONE',
256243
'NOT',
@@ -278,11 +265,9 @@ export const keywords: string[] = [
278265
'ROWS',
279266
'SELECT',
280267
'SET',
281-
'SMALLINT',
282268
'TABLE',
283269
'TABLESAMPLE',
284270
'THEN',
285-
'TIMESTAMP',
286271
'TO',
287272
'TRANSFORM',
288273
'TRIGGER',
@@ -296,7 +281,6 @@ export const keywords: string[] = [
296281
'USING',
297282
'UTC_TMESTAMP',
298283
'VALUES',
299-
'VARCHAR',
300284
'WHEN',
301285
'WHERE',
302286
'WINDOW',
@@ -315,11 +299,8 @@ export const keywords: string[] = [
315299
'DAYOFWEEK',
316300
'EXTRACT',
317301
'FLOOR',
318-
'INTEGER',
319-
'PRECISION',
320302
'VIEWS',
321303
'TIME',
322-
'NUMERIC',
323304
'SYNC',
324305

325306
// fileTypes
@@ -335,3 +316,26 @@ export const keywords: string[] = [
335316
'INPUTFORMAT',
336317
'OUTPUTFORMAT',
337318
];
319+
320+
export const dataTypes: string[] = [
321+
// https://cwiki.apache.org/confluence/display/Hive/LanguageManual+Types
322+
'ARRAY',
323+
'BIGINT',
324+
'BINARY',
325+
'BOOLEAN',
326+
'CHAR',
327+
'DATE',
328+
'DECIMAL',
329+
'DOUBLE',
330+
'FLOAT',
331+
'INT',
332+
'INTEGER',
333+
'INTERVAL',
334+
'MAP',
335+
'NUMERIC',
336+
'PRECISION',
337+
'SMALLINT',
338+
'STRUCT',
339+
'TIMESTAMP',
340+
'VARCHAR',
341+
];

src/languages/mariadb/mariadb.formatter.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { DialectOptions } from '../../dialect.js';
22
import { expandPhrases } from '../../expandPhrases.js';
33
import { postProcess } from './likeMariaDb.js';
4-
import { keywords } from './mariadb.keywords.js';
4+
import { dataTypes, keywords } from './mariadb.keywords.js';
55
import { functions } from './mariadb.functions.js';
66

77
const reservedSelect = expandPhrases(['SELECT [ALL | DISTINCT | DISTINCTROW]']);
@@ -274,6 +274,7 @@ export const mariadb: DialectOptions = {
274274
reservedPhrases,
275275
supportsXor: true,
276276
reservedKeywords: keywords,
277+
reservedDataTypes: dataTypes,
277278
reservedFunctionNames: functions,
278279
// TODO: support _ char set prefixes such as _utf8, _latin1, _binary, _utf8mb4, etc.
279280
stringTypes: [

0 commit comments

Comments
 (0)