diff --git a/src/languages/bigquery/bigquery.keywords.ts b/src/languages/bigquery/bigquery.keywords.ts index a1a852ba3c..6059c4e445 100644 --- a/src/languages/bigquery/bigquery.keywords.ts +++ b/src/languages/bigquery/bigquery.keywords.ts @@ -3,7 +3,6 @@ export const keywords: string[] = [ 'ALL', 'AND', 'ANY', - 'ARRAY', 'AS', 'ASC', 'ASSERT_ROWS_MODIFIED', @@ -80,7 +79,6 @@ export const keywords: string[] = [ 'SELECT', 'SET', 'SOME', - 'STRUCT', 'TABLE', 'TABLESAMPLE', 'THEN', diff --git a/src/languages/db2i/db2i.formatter.ts b/src/languages/db2i/db2i.formatter.ts index 262deeb920..1bdf258f7a 100644 --- a/src/languages/db2i/db2i.formatter.ts +++ b/src/languages/db2i/db2i.formatter.ts @@ -1,7 +1,7 @@ import { DialectOptions } from '../../dialect.js'; import { expandPhrases } from '../../expandPhrases.js'; import { functions } from './db2i.functions.js'; -import { keywords } from './db2i.keywords.js'; +import { dataTypes, keywords } from './db2i.keywords.js'; const reservedSelect = expandPhrases(['SELECT [ALL | DISTINCT]']); @@ -161,7 +161,9 @@ export const db2i: DialectOptions = { reservedSetOperations, reservedJoins, reservedPhrases, - reservedKeywords: keywords, + reservedKeywords: + // Temporary, will be replaced by reservedDataTypes + [...new Set(keywords.concat(dataTypes))], reservedFunctionNames: functions, nestedBlockComments: true, extraParens: ['[]'], diff --git a/src/languages/db2i/db2i.keywords.ts b/src/languages/db2i/db2i.keywords.ts index ace8fd82b8..9e54732fca 100644 --- a/src/languages/db2i/db2i.keywords.ts +++ b/src/languages/db2i/db2i.keywords.ts @@ -32,10 +32,7 @@ export const keywords: string[] = [ 'BEFORE', 'BEGIN', 'BETWEEN', - 'BINARY', 'BIND', - 'BIT', - 'BOOLEAN', 'BSON', 'BUFFERPOOL', 'BY', @@ -45,9 +42,6 @@ export const keywords: string[] = [ 'CARDINALITY', 'CASE', 'CAST', - 'CCSID', - 'CHAR', - 'CHARACTER', 'CHECK', 'CL', 'CLOSE', @@ -90,11 +84,9 @@ export const keywords: string[] = [ 'CURRENT_USER', 'CURSOR', 'CYCLE', - 'DATA', 'DATABASE', 'DATAPARTITIONNAME', 'DATAPARTITIONNUM', - 'DATE', 'DAY', 'DAYS', 'DB2GENERAL', @@ -127,7 +119,6 @@ export const keywords: string[] = [ 'DISTINCT', 'DO', 'DOCUMENT', - 'DOUBLE', 'DROP', 'DYNAMIC', 'EACH', @@ -177,7 +168,6 @@ export const keywords: string[] = [ 'GO', 'GOTO', 'GRANT', - 'GRAPHIC', 'GROUP', 'HANDLER', 'HASH', @@ -256,7 +246,6 @@ export const keywords: string[] = [ 'LOCKSIZE', 'LOG', 'LOGGED', - 'LONG', 'LOOP', 'MAINTAINED', 'MASK', @@ -436,8 +425,6 @@ export const keywords: string[] = [ 'TAG', 'THEN', 'THREADSAFE', - 'TIME', - 'TIMESTAMP', 'TO', 'TRANSACTION', 'TRANSFER', @@ -508,3 +495,37 @@ export const keywords: string[] = [ 'YES', 'ZONE', ]; + +export const dataTypes: string[] = [ + // https://www.ibm.com/docs/en/i/7.2?topic=iaodsd-odbc-data-types-how-they-correspond-db2-i-database-types + 'BIGINT', + 'BINARY', + 'BIT', + 'BLOB', + 'BOOLEAN', + 'CCSID', + 'CHAR', + 'CHARACTER', + 'CLOB', + 'DATA', + 'DATALINK', + 'DATE', + 'DBCLOB', + 'DECFLOAT', + 'DECIMAL', + 'DOUBLE', + 'FLOAT', + 'GRAPHIC', + 'INTEGER', + 'LONG', + 'NUMERIC', + 'REAL', + 'ROWID', + 'SMALLINT', + 'TIME', + 'TIMESTAMP', + 'VARBINARY', + 'VARCHAR', + 'VARGRAPHIC', + 'XML', +]; diff --git a/src/languages/hive/hive.formatter.ts b/src/languages/hive/hive.formatter.ts index 9a1c7b358e..33386d5e7e 100644 --- a/src/languages/hive/hive.formatter.ts +++ b/src/languages/hive/hive.formatter.ts @@ -1,7 +1,7 @@ import { DialectOptions } from '../../dialect.js'; import { expandPhrases } from '../../expandPhrases.js'; import { functions } from './hive.functions.js'; -import { keywords } from './hive.keywords.js'; +import { dataTypes, keywords } from './hive.keywords.js'; const reservedSelect = expandPhrases(['SELECT [ALL | DISTINCT]']); @@ -90,7 +90,9 @@ export const hive: DialectOptions = { reservedSetOperations, reservedJoins, reservedPhrases, - reservedKeywords: keywords, + reservedKeywords: + // Temporary, will be replaced by reservedDataTypes + [...new Set(keywords.concat(dataTypes))], reservedFunctionNames: functions, extraParens: ['[]'], stringTypes: ['""-bs', "''-bs"], diff --git a/src/languages/hive/hive.keywords.ts b/src/languages/hive/hive.keywords.ts index a747ee7641..27c47287cd 100644 --- a/src/languages/hive/hive.keywords.ts +++ b/src/languages/hive/hive.keywords.ts @@ -126,7 +126,6 @@ export const keywords: string[] = [ 'STORED', 'STREAMTABLE', 'STRING', - 'STRUCT', 'TABLES', 'TBLPROPERTIES', 'TEMPORARY', @@ -186,18 +185,13 @@ export const keywords: string[] = [ 'ALL', 'ALTER', 'AND', - 'ARRAY', 'AS', 'AUTHORIZATION', 'BETWEEN', - 'BIGINT', - 'BINARY', - 'BOOLEAN', 'BOTH', 'BY', 'CASE', 'CAST', - 'CHAR', 'COLUMN', 'CONF', 'CREATE', @@ -208,12 +202,9 @@ export const keywords: string[] = [ 'CURRENT_TIMESTAMP', 'CURSOR', 'DATABASE', - 'DATE', - 'DECIMAL', 'DELETE', 'DESCRIBE', 'DISTINCT', - 'DOUBLE', 'DROP', 'ELSE', 'END', @@ -223,7 +214,6 @@ export const keywords: string[] = [ 'EXTERNAL', 'FALSE', 'FETCH', - 'FLOAT', 'FOLLOWING', 'FOR', 'FROM', @@ -238,9 +228,7 @@ export const keywords: string[] = [ 'IN', 'INNER', 'INSERT', - 'INT', 'INTERSECT', - 'INTERVAL', 'INTO', 'IS', 'JOIN', @@ -250,7 +238,6 @@ export const keywords: string[] = [ 'LIKE', 'LOCAL', 'MACRO', - 'MAP', 'MORE', 'NONE', 'NOT', @@ -278,11 +265,9 @@ export const keywords: string[] = [ 'ROWS', 'SELECT', 'SET', - 'SMALLINT', 'TABLE', 'TABLESAMPLE', 'THEN', - 'TIMESTAMP', 'TO', 'TRANSFORM', 'TRIGGER', @@ -296,7 +281,6 @@ export const keywords: string[] = [ 'USING', 'UTC_TMESTAMP', 'VALUES', - 'VARCHAR', 'WHEN', 'WHERE', 'WINDOW', @@ -315,11 +299,8 @@ export const keywords: string[] = [ 'DAYOFWEEK', 'EXTRACT', 'FLOOR', - 'INTEGER', - 'PRECISION', 'VIEWS', 'TIME', - 'NUMERIC', 'SYNC', // fileTypes @@ -335,3 +316,26 @@ export const keywords: string[] = [ 'INPUTFORMAT', 'OUTPUTFORMAT', ]; + +export const dataTypes: string[] = [ + // https://cwiki.apache.org/confluence/display/Hive/LanguageManual+Types + 'ARRAY', + 'BIGINT', + 'BINARY', + 'BOOLEAN', + 'CHAR', + 'DATE', + 'DECIMAL', + 'DOUBLE', + 'FLOAT', + 'INT', + 'INTEGER', + 'INTERVAL', + 'MAP', + 'NUMERIC', + 'PRECISION', + 'SMALLINT', + 'STRUCT', + 'TIMESTAMP', + 'VARCHAR', +]; diff --git a/src/languages/mariadb/mariadb.formatter.ts b/src/languages/mariadb/mariadb.formatter.ts index 6007a2279f..7f2ee9ad44 100644 --- a/src/languages/mariadb/mariadb.formatter.ts +++ b/src/languages/mariadb/mariadb.formatter.ts @@ -1,7 +1,7 @@ import { DialectOptions } from '../../dialect.js'; import { expandPhrases } from '../../expandPhrases.js'; import { postProcess } from './likeMariaDb.js'; -import { keywords } from './mariadb.keywords.js'; +import { dataTypes, keywords } from './mariadb.keywords.js'; import { functions } from './mariadb.functions.js'; const reservedSelect = expandPhrases(['SELECT [ALL | DISTINCT | DISTINCTROW]']); @@ -273,7 +273,9 @@ export const mariadb: DialectOptions = { reservedJoins, reservedPhrases, supportsXor: true, - reservedKeywords: keywords, + reservedKeywords: + // Temporary, will be replaced by reservedDataTypes + [...new Set(keywords.concat(dataTypes))], reservedFunctionNames: functions, // TODO: support _ char set prefixes such as _utf8, _latin1, _binary, _utf8mb4, etc. stringTypes: [ diff --git a/src/languages/mariadb/mariadb.keywords.ts b/src/languages/mariadb/mariadb.keywords.ts index b8fdfa6846..d9fea8da11 100644 --- a/src/languages/mariadb/mariadb.keywords.ts +++ b/src/languages/mariadb/mariadb.keywords.ts @@ -11,17 +11,12 @@ export const keywords: string[] = [ 'ASENSITIVE', 'BEFORE', 'BETWEEN', - 'BIGINT', - 'BINARY', - 'BLOB', 'BOTH', 'BY', 'CALL', 'CASCADE', 'CASE', 'CHANGE', - 'CHAR', - 'CHARACTER', 'CHECK', 'COLLATE', 'COLUMN', @@ -43,8 +38,6 @@ export const keywords: string[] = [ 'DAY_MICROSECOND', 'DAY_MINUTE', 'DAY_SECOND', - 'DEC', - 'DECIMAL', 'DECLARE', 'DEFAULT', 'DELAYED', @@ -57,7 +50,6 @@ export const keywords: string[] = [ 'DISTINCTROW', 'DIV', 'DO_DOMAIN_IDS', - 'DOUBLE', 'DROP', 'DUAL', 'EACH', @@ -71,9 +63,6 @@ export const keywords: string[] = [ 'EXPLAIN', 'FALSE', 'FETCH', - 'FLOAT', - 'FLOAT4', - 'FLOAT8', 'FOR', 'FORCE', 'FOREIGN', @@ -98,13 +87,6 @@ export const keywords: string[] = [ 'INOUT', 'INSENSITIVE', 'INSERT', - 'INT', - 'INT1', - 'INT2', - 'INT3', - 'INT4', - 'INT8', - 'INTEGER', 'INTERSECT', 'INTERVAL', 'INTO', @@ -125,19 +107,12 @@ export const keywords: string[] = [ 'LOCALTIME', 'LOCALTIMESTAMP', 'LOCK', - 'LONG', - 'LONGBLOB', - 'LONGTEXT', 'LOOP', 'LOW_PRIORITY', 'MASTER_HEARTBEAT_PERIOD', 'MASTER_SSL_VERIFY_SERVER_CERT', 'MATCH', 'MAXVALUE', - 'MEDIUMBLOB', - 'MEDIUMINT', - 'MEDIUMTEXT', - 'MIDDLEINT', 'MINUTE_MICROSECOND', 'MINUTE_SECOND', 'MOD', @@ -146,7 +121,6 @@ export const keywords: string[] = [ 'NOT', 'NO_WRITE_TO_BINLOG', 'NULL', - 'NUMERIC', 'OFFSET', 'ON', 'OPTIMIZE', @@ -162,7 +136,6 @@ export const keywords: string[] = [ 'PARSE_VCOL_EXPR', 'PARTITION', 'POSITION', - 'PRECISION', 'PRIMARY', 'PROCEDURE', 'PURGE', @@ -170,7 +143,6 @@ export const keywords: string[] = [ 'READ', 'READS', 'READ_WRITE', - 'REAL', 'RECURSIVE', 'REF_SYSTEM_ID', 'REFERENCES', @@ -199,7 +171,6 @@ export const keywords: string[] = [ 'SHOW', 'SIGNAL', 'SLOW', - 'SMALLINT', 'SPATIAL', 'SPECIFIC', 'SQL', @@ -218,9 +189,6 @@ export const keywords: string[] = [ 'TABLE', 'TERMINATED', 'THEN', - 'TINYBLOB', - 'TINYINT', - 'TINYTEXT', 'TO', 'TRAILING', 'TRIGGER', @@ -238,10 +206,6 @@ export const keywords: string[] = [ 'UTC_TIME', 'UTC_TIMESTAMP', 'VALUES', - 'VARBINARY', - 'VARCHAR', - 'VARCHARACTER', - 'VARYING', 'WHEN', 'WHERE', 'WHILE', @@ -252,3 +216,43 @@ export const keywords: string[] = [ 'YEAR_MONTH', 'ZEROFILL', ]; + +export const dataTypes: string[] = [ + // https://mariadb.com/kb/en/data-types/ + 'BIGINT', + 'BINARY', + 'BLOB', + 'CHAR', + 'CHARACTER', + 'DEC', + 'DECIMAL', + 'DOUBLE', + 'FLOAT', + 'FLOAT4', + 'FLOAT8', + 'INT', + 'INT1', + 'INT2', + 'INT3', + 'INT4', + 'INT8', + 'INTEGER', + 'LONG', + 'LONGBLOB', + 'LONGTEXT', + 'MEDIUMBLOB', + 'MEDIUMINT', + 'MEDIUMTEXT', + 'MIDDLEINT', + 'NUMERIC', + 'PRECISION', + 'REAL', + 'SMALLINT', + 'TINYBLOB', + 'TINYINT', + 'TINYTEXT', + 'VARBINARY', + 'VARCHAR', + 'VARCHARACTER', + 'VARYING', +]; diff --git a/src/languages/mysql/mysql.formatter.ts b/src/languages/mysql/mysql.formatter.ts index 0e40291c03..4bce901a96 100644 --- a/src/languages/mysql/mysql.formatter.ts +++ b/src/languages/mysql/mysql.formatter.ts @@ -1,7 +1,7 @@ import { DialectOptions } from '../../dialect.js'; import { expandPhrases } from '../../expandPhrases.js'; import { postProcess } from '../mariadb/likeMariaDb.js'; -import { keywords } from './mysql.keywords.js'; +import { dataTypes, keywords } from './mysql.keywords.js'; import { functions } from './mysql.functions.js'; const reservedSelect = expandPhrases(['SELECT [ALL | DISTINCT | DISTINCTROW]']); @@ -240,7 +240,9 @@ export const mysql: DialectOptions = { reservedJoins, reservedPhrases, supportsXor: true, - reservedKeywords: keywords, + reservedKeywords: + // Temporary, will be replaced by reservedDataTypes + [...new Set(keywords.concat(dataTypes))], reservedFunctionNames: functions, // TODO: support _ char set prefixes such as _utf8, _latin1, _binary, _utf8mb4, etc. stringTypes: [ diff --git a/src/languages/mysql/mysql.keywords.ts b/src/languages/mysql/mysql.keywords.ts index 0bb84f0e05..bbbf5be7f9 100644 --- a/src/languages/mysql/mysql.keywords.ts +++ b/src/languages/mysql/mysql.keywords.ts @@ -11,17 +11,12 @@ export const keywords: string[] = [ 'ASENSITIVE', // (R) 'BEFORE', // (R) 'BETWEEN', // (R) - 'BIGINT', // (R) - 'BINARY', // (R) - 'BLOB', // (R) 'BOTH', // (R) 'BY', // (R) 'CALL', // (R) 'CASCADE', // (R) 'CASE', // (R) 'CHANGE', // (R) - 'CHAR', // (R) - 'CHARACTER', // (R) 'CHECK', // (R) 'COLLATE', // (R) 'COLUMN', // (R) @@ -44,8 +39,6 @@ export const keywords: string[] = [ 'DAY_MICROSECOND', // (R) 'DAY_MINUTE', // (R) 'DAY_SECOND', // (R) - 'DEC', // (R) - 'DECIMAL', // (R) 'DECLARE', // (R) 'DEFAULT', // (R) 'DELAYED', // (R) @@ -57,7 +50,6 @@ export const keywords: string[] = [ 'DISTINCT', // (R) 'DISTINCTROW', // (R) 'DIV', // (R) - 'DOUBLE', // (R) 'DROP', // (R) 'DUAL', // (R) 'EACH', // (R) @@ -73,9 +65,6 @@ export const keywords: string[] = [ 'FALSE', // (R) 'FETCH', // (R) 'FIRST_VALUE', // (R) - 'FLOAT', // (R) - 'FLOAT4', // (R) - 'FLOAT8', // (R) 'FOR', // (R) 'FORCE', // (R) 'FOREIGN', // (R) @@ -103,13 +92,6 @@ export const keywords: string[] = [ 'INSENSITIVE', // (R) 'INSERT', // (R) 'IN', // <-- moved over from functions - 'INT', // (R) - 'INT1', // (R) - 'INT2', // (R) - 'INT3', // (R) - 'INT4', // (R) - 'INT8', // (R) - 'INTEGER', // (R) 'INTERSECT', // (R) 'INTERVAL', // (R) 'INTO', // (R) @@ -138,18 +120,12 @@ export const keywords: string[] = [ 'LOCALTIMESTAMP', // (R) 'LOCK', // (R) 'LONG', // (R) - 'LONGBLOB', // (R) - 'LONGTEXT', // (R) 'LOOP', // (R) 'LOW_PRIORITY', // (R) 'MASTER_BIND', // (R) 'MASTER_SSL_VERIFY_SERVER_CERT', // (R) 'MATCH', // (R) 'MAXVALUE', // (R) - 'MEDIUMBLOB', // (R) - 'MEDIUMINT', // (R) - 'MEDIUMTEXT', // (R) - 'MIDDLEINT', // (R) 'MINUTE_MICROSECOND', // (R) 'MINUTE_SECOND', // (R) 'MOD', // (R) @@ -160,7 +136,6 @@ export const keywords: string[] = [ 'NTH_VALUE', // (R) 'NTILE', // (R) 'NULL', // (R) - 'NUMERIC', // (R) 'OF', // (R) 'ON', // (R) 'OPTIMIZE', // (R) @@ -175,7 +150,6 @@ export const keywords: string[] = [ 'OVER', // (R) 'PARTITION', // (R) 'PERCENT_RANK', // (R) - 'PRECISION', // (R) 'PRIMARY', // (R) 'PROCEDURE', // (R) 'PURGE', // (R) @@ -184,7 +158,6 @@ export const keywords: string[] = [ 'READ', // (R) 'READS', // (R) 'READ_WRITE', // (R) - 'REAL', // (R) 'RECURSIVE', // (R) 'REFERENCES', // (R) 'REGEXP', // (R) @@ -211,7 +184,6 @@ export const keywords: string[] = [ 'SET', // (R) 'SHOW', // (R) 'SIGNAL', // (R) - 'SMALLINT', // (R) 'SPATIAL', // (R) 'SPECIFIC', // (R) 'SQL', // (R) @@ -229,9 +201,6 @@ export const keywords: string[] = [ 'TABLE', // (R) 'TERMINATED', // (R) 'THEN', // (R) - 'TINYBLOB', // (R) - 'TINYINT', // (R) - 'TINYTEXT', // (R) 'TO', // (R) 'TRAILING', // (R) 'TRIGGER', // (R) @@ -249,10 +218,6 @@ export const keywords: string[] = [ 'UTC_TIME', // (R) 'UTC_TIMESTAMP', // (R) 'VALUES', // (R) - 'VARBINARY', // (R) - 'VARCHAR', // (R) - 'VARCHARACTER', // (R) - 'VARYING', // (R) 'VIRTUAL', // (R) 'WHEN', // (R) 'WHERE', // (R) @@ -264,3 +229,42 @@ export const keywords: string[] = [ 'YEAR_MONTH', // (R) 'ZEROFILL', // (R) ]; + +export const dataTypes: string[] = [ + // https://dev.mysql.com/doc/refman/8.0/en/data-types.html + 'BIGINT', // (R) + 'BINARY', // (R) + 'BLOB', // (R) + 'CHAR', // (R) + 'CHARACTER', // (R) + 'DEC', // (R) + 'DECIMAL', // (R) + 'DOUBLE', // (R) + 'FLOAT', // (R) + 'FLOAT4', // (R) + 'FLOAT8', // (R) + 'INT', // (R) + 'INT1', // (R) + 'INT2', // (R) + 'INT3', // (R) + 'INT4', // (R) + 'INT8', // (R) + 'INTEGER', // (R) + 'LONGBLOB', // (R) + 'LONGTEXT', // (R) + 'MEDIUMBLOB', // (R) + 'MEDIUMINT', // (R) + 'MEDIUMTEXT', // (R) + 'MIDDLEINT', // (R) + 'NUMERIC', // (R) + 'PRECISION', // (R) + 'REAL', // (R) + 'SMALLINT', // (R) + 'TINYBLOB', // (R) + 'TINYINT', // (R) + 'TINYTEXT', // (R) + 'VARBINARY', // (R) + 'VARCHAR', // (R) + 'VARCHARACTER', // (R) + 'VARYING', // (R) +]; diff --git a/src/languages/n1ql/n1ql.formatter.ts b/src/languages/n1ql/n1ql.formatter.ts index 7d71195a90..63a579c9cb 100644 --- a/src/languages/n1ql/n1ql.formatter.ts +++ b/src/languages/n1ql/n1ql.formatter.ts @@ -1,7 +1,7 @@ import { DialectOptions } from '../../dialect.js'; import { expandPhrases } from '../../expandPhrases.js'; import { functions } from './n1ql.functions.js'; -import { keywords } from './n1ql.keywords.js'; +import { dataTypes, keywords } from './n1ql.keywords.js'; const reservedSelect = expandPhrases(['SELECT [ALL | DISTINCT]']); @@ -92,7 +92,9 @@ export const n1ql: DialectOptions = { reservedJoins, reservedPhrases, supportsXor: true, - reservedKeywords: keywords, + reservedKeywords: + // Temporary, will be replaced by reservedDataTypes + [...new Set(keywords.concat(dataTypes))], reservedFunctionNames: functions, // NOTE: single quotes are actually not supported in N1QL, // but we support them anyway as all other SQL dialects do, diff --git a/src/languages/n1ql/n1ql.keywords.ts b/src/languages/n1ql/n1ql.keywords.ts index 825739a7a4..43f083ee44 100644 --- a/src/languages/n1ql/n1ql.keywords.ts +++ b/src/languages/n1ql/n1ql.keywords.ts @@ -6,14 +6,11 @@ export const keywords: string[] = [ 'ANALYZE', 'AND', 'ANY', - 'ARRAY', 'AS', 'ASC', 'AT', 'BEGIN', 'BETWEEN', - 'BINARY', - 'BOOLEAN', 'BREAK', 'BUCKET', 'BUILD', @@ -118,8 +115,6 @@ export const keywords: string[] = [ 'NTH_VALUE', 'NULL', 'NULLS', - 'NUMBER', - 'OBJECT', 'OFFSET', 'ON', 'OPTION', @@ -168,7 +163,6 @@ export const keywords: string[] = [ 'SOME', 'START', 'STATISTICS', - 'STRING', 'SYSTEM', 'THEN', 'TIES', @@ -205,3 +199,13 @@ export const keywords: string[] = [ 'WORK', 'XOR', ]; + +export const dataTypes: string[] = [ + // https://docs.couchbase.com/server/current/n1ql/n1ql-language-reference/datatypes.html + 'ARRAY', + 'BINARY', + 'BOOLEAN', + 'NUMBER', + 'OBJECT', + 'STRING', +]; diff --git a/src/languages/plsql/plsql.formatter.ts b/src/languages/plsql/plsql.formatter.ts index bf94819286..f73c33d2de 100644 --- a/src/languages/plsql/plsql.formatter.ts +++ b/src/languages/plsql/plsql.formatter.ts @@ -1,7 +1,7 @@ import { DialectOptions } from '../../dialect.js'; import { expandPhrases } from '../../expandPhrases.js'; import { EOF_TOKEN, isReserved, isToken, Token, TokenType } from '../../lexer/token.js'; -import { keywords } from './plsql.keywords.js'; +import { dataTypes, keywords } from './plsql.keywords.js'; import { functions } from './plsql.functions.js'; const reservedSelect = expandPhrases(['SELECT [ALL | DISTINCT | UNIQUE]']); @@ -90,7 +90,9 @@ export const plsql: DialectOptions = { reservedJoins, reservedPhrases, supportsXor: true, - reservedKeywords: keywords, + reservedKeywords: + // Temporary, will be replaced by reservedDataTypes + [...new Set(keywords.concat(dataTypes))], reservedFunctionNames: functions, stringTypes: [ { quote: "''-qq", prefixes: ['N'] }, diff --git a/src/languages/plsql/plsql.keywords.ts b/src/languages/plsql/plsql.keywords.ts index 88dec949ea..c4d92afb7b 100644 --- a/src/languages/plsql/plsql.keywords.ts +++ b/src/languages/plsql/plsql.keywords.ts @@ -8,7 +8,6 @@ export const keywords: string[] = [ 'ALTER', 'AND', 'ANY', - 'ARRAY', 'ARROW', 'AS', 'ASC', @@ -18,9 +17,6 @@ export const keywords: string[] = [ 'AVG', 'BEGIN', 'BETWEEN', - 'BFILE_BASE', - 'BINARY', - 'BLOB_BASE', 'BLOCK', 'BODY', 'BOTH', @@ -33,14 +29,10 @@ export const keywords: string[] = [ 'CALLING', 'CASCADE', 'CASE', - 'CHAR', - 'CHAR_BASE', - 'CHARACTER', 'CHARSET', 'CHARSETFORM', 'CHARSETID', 'CHECK', - 'CLOB_BASE', 'CLOSE', 'CLUSTER', 'CLUSTERS', @@ -65,10 +57,7 @@ export const keywords: string[] = [ 'CUSTOMDATUM', 'DANGLING', 'DATA', - 'DATE', - 'DATE_BASE', 'DAY', - 'DECIMAL', 'DECLARE', 'DEFAULT', 'DEFINE', @@ -76,7 +65,6 @@ export const keywords: string[] = [ 'DESC', 'DETERMINISTIC', 'DISTINCT', - 'DOUBLE', 'DROP', 'DURATION', 'ELEMENT', @@ -96,7 +84,6 @@ export const keywords: string[] = [ 'FETCH', 'FINAL', 'FIXED', - 'FLOAT', 'FOR', 'FORALL', 'FORCE', @@ -124,7 +111,6 @@ export const keywords: string[] = [ 'INFINITE', 'INSERT', 'INSTANTIABLE', - 'INT', 'INTERFACE', 'INTERSECT', 'INTERVAL', @@ -147,7 +133,6 @@ export const keywords: string[] = [ 'LIMITED', 'LOCAL', 'LOCK', - 'LONG', 'LOOP', 'MAP', 'MAX', @@ -166,14 +151,12 @@ export const keywords: string[] = [ 'NAN', 'NATIONAL', 'NATIVE', - 'NCHAR', 'NEW', 'NOCOMPRESS', 'NOCOPY', 'NOT', 'NOWAIT', 'NULL', - 'NUMBER_BASE', 'OBJECT', 'OCICOLL', 'OCIDATE', @@ -215,14 +198,12 @@ export const keywords: string[] = [ 'PIPE', 'PIPELINED', 'PRAGMA', - 'PRECISION', 'PRIOR', 'PRIVATE', 'PROCEDURE', 'PUBLIC', 'RAISE', 'RANGE', - 'RAW', 'READ', 'RECORD', 'REF', @@ -283,7 +264,6 @@ export const keywords: string[] = [ 'THE', 'THEN', 'TIME', - 'TIMESTAMP', 'TIMEZONE_ABBR', 'TIMEZONE_HOUR', 'TIMEZONE_MINUTE', @@ -311,7 +291,6 @@ export const keywords: string[] = [ 'VARIABLE', 'VARIANCE', 'VARRAY', - 'VARYING', 'VIEW', 'VIEWS', 'VOID', @@ -325,3 +304,29 @@ export const keywords: string[] = [ 'YEAR', 'ZONE', ]; + +export const dataTypes: string[] = [ + // https://www.ibm.com/docs/en/db2/10.5?topic=plsql-data-types + 'ARRAY', + 'BFILE_BASE', + 'BINARY', + 'BLOB_BASE', + 'CHAR', + 'CHAR_BASE', + 'CHARACTER', + 'CLOB_BASE', + 'DATE', + 'DATE_BASE', + 'DECIMAL', + 'DOUBLE', + 'FLOAT', + 'INT', + 'LONG', + 'NCHAR', + 'NUMBER_BASE', + 'PRECISION', + 'RAW', + 'TIMESTAMP', + 'VARCHAR', + 'VARYING', +]; diff --git a/src/languages/postgresql/postgresql.keywords.ts b/src/languages/postgresql/postgresql.keywords.ts index aaffb7d078..dcee480006 100644 --- a/src/languages/postgresql/postgresql.keywords.ts +++ b/src/languages/postgresql/postgresql.keywords.ts @@ -16,7 +16,6 @@ export const keywords = [ 'ANALYZE', // reserved 'AND', // reserved 'ANY', // reserved - 'ARRAY', // reserved, requires AS 'AS', // reserved, requires AS 'ASC', // reserved 'ASENSITIVE', @@ -439,6 +438,7 @@ export const keywords = [ export const dataTypes: string[] = [ // https://www.postgresql.org/docs/current/datatype.html + 'ARRAY', // reserved, requires AS 'BIGINT', // (cannot be function or type) 'BIT', // (cannot be function or type) 'BOOL', // (cannot be function or type) diff --git a/src/languages/redshift/redshift.keywords.ts b/src/languages/redshift/redshift.keywords.ts index 73b6441464..dbf1afe492 100644 --- a/src/languages/redshift/redshift.keywords.ts +++ b/src/languages/redshift/redshift.keywords.ts @@ -5,7 +5,6 @@ export const keywords: string[] = [ 'ALL', 'ALLOWOVERWRITE', 'ANY', - 'ARRAY', 'AS', 'ASC', 'AUTHORIZATION', @@ -201,6 +200,7 @@ export const keywords: string[] = [ export const dataTypes: string[] = [ // https://docs.aws.amazon.com/redshift/latest/dg/r_Character_types.html#r_Character_types-text-and-bpchar-types + 'ARRAY', 'BPCHAR', 'TEXT', ]; diff --git a/src/languages/spark/spark.formatter.ts b/src/languages/spark/spark.formatter.ts index 05672bac57..fadbbfe878 100644 --- a/src/languages/spark/spark.formatter.ts +++ b/src/languages/spark/spark.formatter.ts @@ -1,7 +1,7 @@ import { DialectOptions } from '../../dialect.js'; import { expandPhrases } from '../../expandPhrases.js'; import { EOF_TOKEN, isToken, Token, TokenType } from '../../lexer/token.js'; -import { keywords } from './spark.keywords.js'; +import { dataTypes, keywords } from './spark.keywords.js'; import { functions } from './spark.functions.js'; // http://spark.apache.org/docs/latest/sql-ref-syntax.html @@ -127,7 +127,9 @@ export const spark: DialectOptions = { reservedJoins, reservedPhrases, supportsXor: true, - reservedKeywords: keywords, + reservedKeywords: + // Temporary, will be replaced by reservedDataTypes + [...new Set(keywords.concat(dataTypes))], reservedFunctionNames: functions, extraParens: ['[]'], stringTypes: [ diff --git a/src/languages/spark/spark.keywords.ts b/src/languages/spark/spark.keywords.ts index fdc6f37bf0..0513c3f711 100644 --- a/src/languages/spark/spark.keywords.ts +++ b/src/languages/spark/spark.keywords.ts @@ -9,7 +9,6 @@ export const keywords: string[] = [ 'ANTI', 'ANY', 'ARCHIVE', - 'ARRAY', 'AS', 'ASC', 'AT', @@ -51,7 +50,6 @@ export const keywords: string[] = [ 'DATA', 'DATABASE', 'DATABASES', - 'DAY', 'DBPROPERTIES', 'DEFINED', 'DELETE', @@ -93,7 +91,6 @@ export const keywords: string[] = [ 'GRANT', 'GROUP', 'GROUPING', - 'HOUR', 'IF', 'IGNORE', 'IMPORT', @@ -104,7 +101,6 @@ export const keywords: string[] = [ 'INPATH', 'INPUTFORMAT', 'INTERSECT', - 'INTERVAL', 'INTO', 'IS', 'ITEMS', @@ -124,11 +120,8 @@ export const keywords: string[] = [ 'LOCKS', 'LOGICAL', 'MACRO', - 'MAP', 'MATCHED', 'MERGE', - 'MINUTE', - 'MONTH', 'MSCK', 'NAMESPACE', 'NAMESPACES', @@ -184,7 +177,6 @@ export const keywords: string[] = [ 'ROW', 'ROWS', 'SCHEMA', - 'SECOND', 'SELECT', 'SEMI', 'SEPARATED', @@ -201,7 +193,6 @@ export const keywords: string[] = [ 'STATISTICS', 'STORED', 'STRATIFY', - 'STRUCT', 'SUBSTR', 'SUBSTRING', 'TABLE', @@ -230,7 +221,6 @@ export const keywords: string[] = [ 'USING', 'VIEW', 'WINDOW', - 'YEAR', // other 'ANALYSE', 'ARRAY_ZIP', @@ -264,10 +254,44 @@ export const keywords: string[] = [ 'REGEXP', 'SEPARATOR', 'SIZE', - 'STRING', 'TYPE', 'TYPES', 'UNSIGNED', 'VARIABLES', 'YEAR_MONTH', ]; + +export const dataTypes: string[] = [ + // https://spark.apache.org/docs/latest/sql-ref-datatypes.html + 'BOOLEAN', + 'BYTE', + 'TINYINT', + 'SHORT', + 'SMALLINT', + 'INT', + 'INTEGER', + 'LONG', + 'BIGINT', + 'FLOAT', + 'REAL', + 'DOUBLE', + 'DATE', + 'TIMESTAMP', + 'TIMESTAMP_LTZ', + 'TIMESTAMP_NTZ', + 'STRING', + 'BINARY', + 'DECIMAL', + 'DEC', + 'NUMERIC', + 'INTERVAL', + 'YEAR', + 'MONTH', + 'DAY', + 'HOUR', + 'MINUTE', + 'SECOND', + 'ARRAY', + 'STRUCT', + 'MAP', +]; diff --git a/src/languages/sql/sql.formatter.ts b/src/languages/sql/sql.formatter.ts index 8baa4c9014..95697e44a6 100644 --- a/src/languages/sql/sql.formatter.ts +++ b/src/languages/sql/sql.formatter.ts @@ -1,7 +1,7 @@ import { DialectOptions } from '../../dialect.js'; import { expandPhrases } from '../../expandPhrases.js'; import { functions } from './sql.functions.js'; -import { keywords } from './sql.keywords.js'; +import { dataTypes, keywords } from './sql.keywords.js'; const reservedSelect = expandPhrases(['SELECT [ALL | DISTINCT]']); @@ -81,7 +81,9 @@ export const sql: DialectOptions = { reservedSetOperations, reservedJoins, reservedPhrases, - reservedKeywords: keywords, + reservedKeywords: + // Temporary, will be replaced by reservedDataTypes + [...new Set(keywords.concat(dataTypes))], reservedFunctionNames: functions, stringTypes: [ { quote: "''-qq-bs", prefixes: ['N', 'U&'] }, diff --git a/src/languages/sql/sql.keywords.ts b/src/languages/sql/sql.keywords.ts index 496dde3015..66e6f7c1e0 100644 --- a/src/languages/sql/sql.keywords.ts +++ b/src/languages/sql/sql.keywords.ts @@ -5,7 +5,6 @@ export const keywords: string[] = [ 'ALTER', 'ANY', // <- moved over from functions 'ARE', - 'ARRAY', 'AS', 'ASENSITIVE', 'ASYMMETRIC', @@ -14,20 +13,13 @@ export const keywords: string[] = [ 'AUTHORIZATION', 'BEGIN', 'BETWEEN', - 'BIGINT', - 'BINARY', - 'BLOB', - 'BOOLEAN', 'BOTH', 'BY', 'CALL', 'CALLED', 'CASCADED', 'CAST', - 'CHAR', - 'CHARACTER', 'CHECK', - 'CLOB', 'CLOSE', 'COALESCE', 'COLLATE', @@ -50,11 +42,7 @@ export const keywords: string[] = [ 'CURRENT_USER', 'CURSOR', 'CYCLE', - 'DATE', - 'DAY', 'DEALLOCATE', - 'DEC', - 'DECIMAL', 'DECLARE', 'DEFAULT', 'DELETE', @@ -63,7 +51,6 @@ export const keywords: string[] = [ 'DETERMINISTIC', 'DISCONNECT', 'DISTINCT', - 'DOUBLE', 'DROP', 'DYNAMIC', 'EACH', @@ -79,7 +66,6 @@ export const keywords: string[] = [ 'FALSE', 'FETCH', 'FILTER', - 'FLOAT', 'FOR', 'FOREIGN', 'FREE', @@ -92,7 +78,6 @@ export const keywords: string[] = [ 'GROUP', 'HAVING', 'HOLD', - 'HOUR', 'IDENTITY', 'IN', 'INDICATOR', @@ -100,10 +85,7 @@ export const keywords: string[] = [ 'INOUT', 'INSENSITIVE', 'INSERT', - 'INT', - 'INTEGER', 'INTERSECT', - 'INTERVAL', 'INTO', 'IS', 'LANGUAGE', @@ -118,22 +100,15 @@ export const keywords: string[] = [ 'MEMBER', 'MERGE', 'METHOD', - 'MINUTE', 'MODIFIES', 'MODULE', - 'MONTH', - 'MULTISET', - 'NATIONAL', 'NATURAL', - 'NCHAR', - 'NCLOB', 'NEW', 'NO', 'NONE', 'NOT', 'NULL', 'NULLIF', - 'NUMERIC', 'OF', 'OLD', 'ON', @@ -177,7 +152,6 @@ export const keywords: string[] = [ 'SESSION_USER', 'SET', 'SIMILAR', - 'SMALLINT', 'SOME', // <- moved over from functions 'SPECIFIC', 'SQL', @@ -193,8 +167,6 @@ export const keywords: string[] = [ 'TABLE', 'TABLESAMPLE', 'THEN', - 'TIME', - 'TIMESTAMP', 'TIMEZONE_HOUR', 'TIMEZONE_MINUTE', 'TO', @@ -213,12 +185,44 @@ export const keywords: string[] = [ 'USING', 'VALUE', 'VALUES', - 'VARBINARY', - 'VARCHAR', - 'VARYING', 'WHENEVER', 'WINDOW', 'WITHIN', 'WITHOUT', +]; + +export const dataTypes: string[] = [ + // https://jakewheat.github.io/sql-overview/sql-2008-foundation-grammar.html#_6_1_data_type + 'ARRAY', + 'BIGINT', + 'BINARY', + 'BLOB', + 'BOOLEAN', + 'CHAR', + 'CHARACTER', + 'CLOB', + 'DATE', + 'DAY', + 'DEC', + 'DECIMAL', + 'DOUBLE', + 'FLOAT', + 'HOUR', + 'INT', + 'INTEGER', + 'INTERVAL', + 'MINUTE', + 'MONTH', + 'MULTISET', + 'NATIONAL', + 'NCHAR', + 'NCLOB', + 'NUMERIC', + 'SMALLINT', + 'TIME', + 'TIMESTAMP', + 'VARBINARY', + 'VARCHAR', + 'VARYING', 'YEAR', ]; diff --git a/src/languages/sqlite/sqlite.formatter.ts b/src/languages/sqlite/sqlite.formatter.ts index 3bcf75beb2..b3c1c166e8 100644 --- a/src/languages/sqlite/sqlite.formatter.ts +++ b/src/languages/sqlite/sqlite.formatter.ts @@ -1,7 +1,7 @@ import { DialectOptions } from '../../dialect.js'; import { expandPhrases } from '../../expandPhrases.js'; import { functions } from './sqlite.functions.js'; -import { keywords } from './sqlite.keywords.js'; +import { dataTypes, keywords } from './sqlite.keywords.js'; const reservedSelect = expandPhrases(['SELECT [ALL | DISTINCT]']); @@ -72,7 +72,9 @@ export const sqlite: DialectOptions = { reservedSetOperations, reservedJoins, reservedPhrases, - reservedKeywords: keywords, + reservedKeywords: + // Temporary, will be replaced by reservedDataTypes + [...new Set(keywords.concat(dataTypes))], reservedFunctionNames: functions, stringTypes: [ "''-qq", diff --git a/src/languages/sqlite/sqlite.keywords.ts b/src/languages/sqlite/sqlite.keywords.ts index 2ab649a7b6..f82376b0ab 100644 --- a/src/languages/sqlite/sqlite.keywords.ts +++ b/src/languages/sqlite/sqlite.keywords.ts @@ -7,9 +7,7 @@ export const keywords: string[] = [ 'ALL', 'ALTER', 'AND', - 'ANY', 'ARE', - 'ARRAY', 'ALWAYS', 'ANALYZE', 'AS', @@ -153,3 +151,15 @@ export const keywords: string[] = [ 'WITH', 'WITHOUT', ]; + +export const dataTypes: string[] = [ + // https://www.sqlite.org/stricttables.html + // https://www.sqlite.org/datatype3.html + 'ANY', + 'ARRAY', + 'BLOB', + 'INT', + 'INTEGER', + 'REAL', + 'TEXT', +]; diff --git a/src/languages/trino/trino.keywords.ts b/src/languages/trino/trino.keywords.ts index dd6c0cddaf..12066f6794 100644 --- a/src/languages/trino/trino.keywords.ts +++ b/src/languages/trino/trino.keywords.ts @@ -9,7 +9,6 @@ export const keywords: string[] = [ 'ANALYZE', 'AND', 'ANY', - 'ARRAY', 'AS', 'ASC', 'AT',