File tree Expand file tree Collapse file tree 2 files changed +12
-2
lines changed
Expand file tree Collapse file tree 2 files changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -44,7 +44,7 @@ def is_keyword(value):
4444 (r'(?<!\w)[$:?]\w+' , tokens .Name .Placeholder ),
4545
4646 (r'\\\w+' , tokens .Command ),
47-
47+ ( r'(NOT\s+)?(IN)\b' , tokens . Operator . Comparison ),
4848 # FIXME(andi): VALUES shouldn't be listed here
4949 # see https://github.com/andialbrecht/sqlparse/pull/64
5050 # AS and IN are special, it may be followed by a parenthesis, but
Original file line number Diff line number Diff line change @@ -371,10 +371,20 @@ def test_grouping_function_not_in():
371371 # issue183
372372 p = sqlparse .parse ('in(1, 2)' )[0 ]
373373 assert len (p .tokens ) == 2
374- assert p .tokens [0 ].ttype == T .Keyword
374+ assert p .tokens [0 ].ttype == T .Comparison
375375 assert isinstance (p .tokens [1 ], sql .Parenthesis )
376376
377377
378+ def test_in_comparison ():
379+ # issue566
380+ p = sqlparse .parse ('a in (1, 2)' )[0 ]
381+ assert len (p .tokens ) == 1
382+ assert isinstance (p .tokens [0 ], sql .Comparison )
383+ assert len (p .tokens [0 ].tokens ) == 5
384+ assert p .tokens [0 ].left .value == 'a'
385+ assert p .tokens [0 ].right .value == '(1, 2)'
386+
387+
378388def test_grouping_varchar ():
379389 p = sqlparse .parse ('"text" Varchar(50) NOT NULL' )[0 ]
380390 assert isinstance (p .tokens [2 ], sql .Function )
You can’t perform that action at this time.
0 commit comments