Skip to content

Commit 28dd0f0

Browse files
committed
Cleanup from review feedback, WIP
1 parent 1c19d1a commit 28dd0f0

File tree

5 files changed

+8
-18
lines changed

5 files changed

+8
-18
lines changed

src/languages/clickhouse/clickhouse.formatter.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -285,13 +285,13 @@ export const clickhouse: DialectOptions = {
285285

286286
/**
287287
* Converts IN and ANY from RESERVED_FUNCTION_NAME to RESERVED_KEYWORD
288-
* when they are used as operators (not function calls).
288+
* when they are used as operators/modifiers (not function calls).
289289
*
290290
* IN operator: foo IN (1, 2, 3) - IN comes after an identifier/expression
291291
* IN function: IN(foo, 1, 2, 3) - IN comes at start or after operators/keywords
292292
*
293-
* ANY operator: foo = ANY (1, 2, 3) - ANY comes after an operator like =
294-
* ANY function: ANY(foo, 1, 2, 3) - ANY comes at start or after operators/keywords
293+
* ANY join modifier: ANY LEFT JOIN, ANY JOIN - ANY comes after an operator
294+
* any() aggregate function: any(column) - selects first encountered value
295295
*/
296296
function postProcess(tokens: Token[]): Token[] {
297297
return tokens.map((token, i) => {

src/languages/clickhouse/clickhouse.keywords.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
export const keywords: string[] = [
22
// Derived from https://github.com/ClickHouse/ClickHouse/blob/827a7ef9f6d727ef511fea7785a1243541509efb/tests/fuzz/dictionaries/keywords.dict#L4
3-
// Clickhouse keywords can span multiple individual words (e.g., "ADD COLUMN"). See
4-
// `keywordPhrases` below for all of these.
53
'ACCESS',
64
'ACTION',
75
'ADD',

test/clickhouse.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,8 @@ describe('ClickhouseFormatter', () => {
6262
supportsInsertInto(format);
6363
supportsUpdate(format);
6464
supportsTruncateTable(format);
65-
supportsStrings(format, ["''-qq-bs"]);
66-
supportsIdentifiers(format, ['""-qq-bs', '``']);
65+
supportsStrings(format, ["''-qq", "''-bs"]);
66+
supportsIdentifiers(format, ['""-qq', '""-bs', '``']);
6767
supportsArrayLiterals(format, { withoutArrayPrefix: true });
6868
supportsBetween(format);
6969
supportsJoin(format, {

test/features/identifiers.ts

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import { FormatFn } from '../../src/sqlFormatter.js';
55
type IdentType =
66
| '""-qq' // with repeated-quote escaping
77
| '""-bs' // with backslash escaping
8-
| '""-qq-bs' // with repeated-quote and backslash escaping
98
| '``' // with repeated-quote escaping
109
| '[]' // with ]] escaping
1110
| 'U&""'; // with repeated-quote escaping
@@ -44,8 +43,8 @@ export default function supportsIdentifiers(format: FormatFn, identifierTypes: I
4443
}
4544

4645
if (identifierTypes.includes('""-bs')) {
47-
it('supports escaping double-quote by escaping it with a backslash', () => {
48-
expect(format('"foo\\"bar"')).toBe('"foo\\"bar"');
46+
it('supports backslash-escaped double-quoted identifiers', () => {
47+
expect(format('"foo \\" JOIN bar"')).toBe('"foo \\" JOIN bar"');
4948
});
5049

5150
if (!identifierTypes.includes('""-qq')) {
@@ -55,12 +54,6 @@ export default function supportsIdentifiers(format: FormatFn, identifierTypes: I
5554
}
5655
}
5756

58-
if (identifierTypes.includes('""-qq-bs')) {
59-
it('supports escaping double-quote with a backslash and a repeated quote', () => {
60-
expect(format('"foo \\" JOIN ""bar"')).toBe('"foo \\" JOIN ""bar"');
61-
});
62-
}
63-
6457
if (identifierTypes.includes('``')) {
6558
it('supports backtick-quoted identifiers', () => {
6659
expect(format('`foo JOIN bar`')).toBe('`foo JOIN bar`');

test/features/strings.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ type StringType =
1010
// Note: ''-qq and ''-bs can be combined to allow for both types of escaping
1111
| "''-qq" // with repeated-quote escaping
1212
| "''-bs" // with backslash escaping
13-
| "''-qq-bs" // with repeated-quote and backslash escaping
1413
| "U&''" // with repeated-quote escaping
1514
| "N''" // with escaping style depending on whether also ''-qq or ''-bs was specified
1615
| "X''" // no escaping
@@ -95,7 +94,7 @@ export default function supportsStrings(format: FormatFn, stringTypes: StringTyp
9594
}
9695
}
9796

98-
if (stringTypes.includes("''-qq-bs")) {
97+
if (stringTypes.includes("''-qq") && stringTypes.includes("''-bs")) {
9998
it('supports escaping single-quote with a backslash and a repeated quote', () => {
10099
expect(format("'foo \\' JOIN ''bar'")).toBe("'foo \\' JOIN ''bar'");
101100
});

0 commit comments

Comments
 (0)