Skip to content

Commit b912e09

Browse files
committed
Remove special casing for in()
1 parent c4bef88 commit b912e09

File tree

2 files changed

+0
-51
lines changed

2 files changed

+0
-51
lines changed

src/languages/clickhouse/clickhouse.formatter.ts

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -300,24 +300,6 @@ function postProcess(tokens: Token[]): Token[] {
300300
const nextToken = tokens[i + 1] || EOF_TOKEN;
301301
const prevToken = tokens[i - 1] || EOF_TOKEN;
302302

303-
// We want to convert IN from RESERVED_KEYWORD to RESERVED_FUNCTION_NAME
304-
// when it's used as a function. Whether it's used as an operator depends on
305-
// the previous token and whether the next token is an opening parenthesis.
306-
if (
307-
isToken.IN(token) &&
308-
!(
309-
prevToken.type === TokenType.IDENTIFIER ||
310-
prevToken.type === TokenType.QUOTED_IDENTIFIER ||
311-
prevToken.type === TokenType.NUMBER ||
312-
prevToken.type === TokenType.STRING ||
313-
prevToken.type === TokenType.CLOSE_PAREN ||
314-
prevToken.type === TokenType.ASTERISK
315-
) &&
316-
nextToken.text === '('
317-
) {
318-
return { ...token, type: TokenType.RESERVED_FUNCTION_NAME };
319-
}
320-
321303
// If we have queries like
322304
// > GRANT SELECT, INSERT ON db.table TO john
323305
// > GRANT SELECT(a, b), SELECT(c) ON db.table TO john

test/clickhouse.test.ts

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -183,39 +183,6 @@ describe('ClickhouseFormatter', () => {
183183
);
184184
});
185185

186-
describe('IN set operator vs function', () => {
187-
it('should respect the IN operator as a keyword when used as an operator', () => {
188-
expect(format('SELECT 1 in foo;')).toBe(dedent`
189-
SELECT
190-
1 in foo;
191-
`);
192-
193-
expect(format('SELECT foo in (1,2,3);')).toBe(dedent`
194-
SELECT
195-
foo in (1, 2, 3);
196-
`);
197-
expect(format('SELECT "foo" in (1,2,3);')).toBe(dedent`
198-
SELECT
199-
"foo" in (1, 2, 3);
200-
`);
201-
expect(format('SELECT 1 in (1,2,3);')).toBe(dedent`
202-
SELECT
203-
1 in (1, 2, 3);
204-
`);
205-
});
206-
207-
it('should respect the IN operator as a keyword when used as a function', () => {
208-
expect(format('SELECT in(foo, [1,2,3]);')).toBe(dedent`
209-
SELECT
210-
in(foo, [1, 2, 3]);
211-
`);
212-
expect(format('SELECT in("foo", "bar");')).toBe(dedent`
213-
SELECT
214-
in("foo", "bar");
215-
`);
216-
});
217-
});
218-
219186
it('should support parameters', () => {
220187
expect(format('SELECT {foo:Uint64};', { params: { foo: "'123'" } })).toBe("SELECT\n '123';");
221188
expect(format('SELECT {foo:Map(String, String)};', { params: { foo: "{'bar': 'baz'}" } })).toBe(

0 commit comments

Comments
 (0)