Skip to content

Commit ccd6342

Browse files
committed
Apparently CASE..END is supported in all dialects
So make it non-optional. Also enabled CASE tests for N1QL where these had been forgotten (had to tweak one test a little, as it contained a function name that's known to N1QL).
1 parent 077575b commit ccd6342

27 files changed

+6
-41
lines changed

src/core/Tokenizer.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ interface TokenizerOptions {
1616
stringTypes: regexFactory.StringPatternType[];
1717
blockStart: string[];
1818
blockEnd: string[];
19-
supportsCase?: boolean;
2019
indexedPlaceholderTypes?: string[];
2120
namedPlaceholderTypes: string[];
2221
lineCommentTypes: string[];
@@ -46,7 +45,6 @@ export default class Tokenizer {
4645
* @param {string[]} cfg.stringTypes - string types to enable - "", '', ``, [], N''
4746
* @param {string[]} cfg.blockStart - Opening parentheses to enable, like (, [
4847
* @param {string[]} cfg.blockEnd - Closing parentheses to enable, like ), ]
49-
* @param {boolean} cfg.supportsCase - True when the dialect supports CASE..END expressions
5048
* @param {string[]} cfg.indexedPlaceholderTypes - Prefixes for indexed placeholders, like ?
5149
* @param {string[]} cfg.namedPlaceholderTypes - Prefixes for named placeholders, like @ and :
5250
* @param {string[]} cfg.lineCommentTypes - Line comments to enable, like # and --
@@ -96,8 +94,8 @@ export default class Tokenizer {
9694
]),
9795
[TokenType.BLOCK_START]: regexFactory.createParenRegex(cfg.blockStart),
9896
[TokenType.BLOCK_END]: regexFactory.createParenRegex(cfg.blockEnd),
99-
[TokenType.RESERVED_CASE_START]: cfg.supportsCase ? /^(CASE)\b/iu : NULL_REGEX,
100-
[TokenType.RESERVED_CASE_END]: cfg.supportsCase ? /^(END)\b/iu : NULL_REGEX,
97+
[TokenType.RESERVED_CASE_START]: /^(CASE)\b/iu,
98+
[TokenType.RESERVED_CASE_END]: /^(END)\b/iu,
10199
[TokenType.LINE_COMMENT]: regexFactory.createLineCommentRegex(cfg.lineCommentTypes),
102100
[TokenType.BLOCK_COMMENT]: /^(\/\*[^]*?(?:\*\/|$))/u,
103101
[TokenType.NUMBER]:

src/languages/bigquery.formatter.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -856,7 +856,6 @@ export default class BigQueryFormatter extends Formatter {
856856
stringTypes: BigQueryFormatter.stringTypes,
857857
blockStart: BigQueryFormatter.blockStart,
858858
blockEnd: BigQueryFormatter.blockEnd,
859-
supportsCase: true,
860859
indexedPlaceholderTypes: BigQueryFormatter.indexedPlaceholderTypes,
861860
namedPlaceholderTypes: BigQueryFormatter.namedPlaceholderTypes,
862861
lineCommentTypes: BigQueryFormatter.lineCommentTypes,

src/languages/db2.formatter.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -889,7 +889,6 @@ export default class Db2Formatter extends Formatter {
889889
stringTypes: Db2Formatter.stringTypes,
890890
blockStart: Db2Formatter.blockStart,
891891
blockEnd: Db2Formatter.blockEnd,
892-
supportsCase: true,
893892
indexedPlaceholderTypes: Db2Formatter.indexedPlaceholderTypes,
894893
namedPlaceholderTypes: Db2Formatter.namedPlaceholderTypes,
895894
lineCommentTypes: Db2Formatter.lineCommentTypes,

src/languages/hive.formatter.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -644,7 +644,6 @@ export default class HiveFormatter extends Formatter {
644644
stringTypes: HiveFormatter.stringTypes,
645645
blockStart: HiveFormatter.blockStart,
646646
blockEnd: HiveFormatter.blockEnd,
647-
supportsCase: true,
648647
indexedPlaceholderTypes: HiveFormatter.indexedPlaceholderTypes,
649648
namedPlaceholderTypes: HiveFormatter.namedPlaceholderTypes,
650649
lineCommentTypes: HiveFormatter.lineCommentTypes,

src/languages/mariadb.formatter.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1182,7 +1182,6 @@ export default class MariaDbFormatter extends Formatter {
11821182
stringTypes: MariaDbFormatter.stringTypes,
11831183
blockStart: MariaDbFormatter.blockStart,
11841184
blockEnd: MariaDbFormatter.blockEnd,
1185-
supportsCase: true,
11861185
indexedPlaceholderTypes: MariaDbFormatter.indexedPlaceholderTypes,
11871186
namedPlaceholderTypes: MariaDbFormatter.namedPlaceholderTypes,
11881187
lineCommentTypes: MariaDbFormatter.lineCommentTypes,

src/languages/mysql.formatter.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1345,7 +1345,6 @@ export default class MySqlFormatter extends Formatter {
13451345
stringTypes: MySqlFormatter.stringTypes,
13461346
blockStart: MySqlFormatter.blockStart,
13471347
blockEnd: MySqlFormatter.blockEnd,
1348-
supportsCase: true,
13491348
indexedPlaceholderTypes: MySqlFormatter.indexedPlaceholderTypes,
13501349
namedPlaceholderTypes: MySqlFormatter.namedPlaceholderTypes,
13511350
lineCommentTypes: MySqlFormatter.lineCommentTypes,

src/languages/n1ql.formatter.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -536,7 +536,6 @@ export default class N1qlFormatter extends Formatter {
536536
stringTypes: N1qlFormatter.stringTypes,
537537
blockStart: N1qlFormatter.blockStart,
538538
blockEnd: N1qlFormatter.blockEnd,
539-
supportsCase: true,
540539
namedPlaceholderTypes: N1qlFormatter.namedPlaceholderTypes,
541540
lineCommentTypes: N1qlFormatter.lineCommentTypes,
542541
operators: N1qlFormatter.operators,

src/languages/plsql.formatter.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -479,7 +479,6 @@ export default class PlSqlFormatter extends Formatter {
479479
stringTypes: PlSqlFormatter.stringTypes,
480480
blockStart: PlSqlFormatter.blockStart,
481481
blockEnd: PlSqlFormatter.blockEnd,
482-
supportsCase: true,
483482
indexedPlaceholderTypes: PlSqlFormatter.indexedPlaceholderTypes,
484483
namedPlaceholderTypes: PlSqlFormatter.namedPlaceholderTypes,
485484
lineCommentTypes: PlSqlFormatter.lineCommentTypes,

src/languages/postgresql.formatter.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1697,7 +1697,6 @@ export default class PostgreSqlFormatter extends Formatter {
16971697
stringTypes: PostgreSqlFormatter.stringTypes,
16981698
blockStart: PostgreSqlFormatter.blockStart,
16991699
blockEnd: PostgreSqlFormatter.blockEnd,
1700-
supportsCase: true,
17011700
indexedPlaceholderTypes: PostgreSqlFormatter.indexedPlaceholderTypes,
17021701
namedPlaceholderTypes: PostgreSqlFormatter.namedPlaceholderTypes,
17031702
lineCommentTypes: PostgreSqlFormatter.lineCommentTypes,

src/languages/redshift.formatter.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -744,7 +744,6 @@ export default class RedshiftFormatter extends Formatter {
744744
stringTypes: RedshiftFormatter.stringTypes,
745745
blockStart: RedshiftFormatter.blockStart,
746746
blockEnd: RedshiftFormatter.blockEnd,
747-
supportsCase: true,
748747
indexedPlaceholderTypes: RedshiftFormatter.indexedPlaceholderTypes,
749748
namedPlaceholderTypes: RedshiftFormatter.namedPlaceholderTypes,
750749
lineCommentTypes: RedshiftFormatter.lineCommentTypes,

0 commit comments

Comments
 (0)