diff options
author | Andi Albrecht <albrecht.andi@gmail.com> | 2022-12-30 10:57:31 +0100 |
---|---|---|
committer | Andi Albrecht <albrecht.andi@gmail.com> | 2022-12-30 10:57:31 +0100 |
commit | e9241945801808d1db7f76bdccbbe9a200042c37 (patch) | |
tree | c596d3faf6328242c024ac636e77fbb76cdda042 | |
parent | 9f44d54c07180b826a6276d3acf5e1458b507c3f (diff) | |
download | sqlparse-e9241945801808d1db7f76bdccbbe9a200042c37.tar.gz |
Revert "add regex pattern to identify IN as a Compasion token"
This reverts commit 28c4d4026e1d9389a99d8cd627c96fa360c17fc4.
See #694. The expectation is that IN is primarily recognized as a keyword,
although it acts as a comparison operator. This also matches the definition of
IN in most SQL syntax references where it is listed as a reserved
keyword (PostgreSQL:
https://www.postgresql.org/docs/current/sql-keywords-appendix.html, MySQL:
https://dev.mysql.com/doc/refman/8.0/en/keywords.html, for example).
-rw-r--r-- | sqlparse/keywords.py | 2 | ||||
-rw-r--r-- | tests/test_grouping.py | 12 |
2 files changed, 2 insertions, 12 deletions
diff --git a/sqlparse/keywords.py b/sqlparse/keywords.py index d73e114..dff5e1c 100644 --- a/sqlparse/keywords.py +++ b/sqlparse/keywords.py @@ -50,7 +50,7 @@ SQL_REGEX = { (r'(?<!\w)[$:?]\w+', tokens.Name.Placeholder), (r'\\\w+', tokens.Command), - (r'(NOT\s+)?(IN)\b', tokens.Operator.Comparison), + # FIXME(andi): VALUES shouldn't be listed here # see https://github.com/andialbrecht/sqlparse/pull/64 # AS and IN are special, it may be followed by a parenthesis, but diff --git a/tests/test_grouping.py b/tests/test_grouping.py index 546ad4b..03d16c5 100644 --- a/tests/test_grouping.py +++ b/tests/test_grouping.py @@ -376,20 +376,10 @@ def test_grouping_function_not_in(): # issue183 p = sqlparse.parse('in(1, 2)')[0] assert len(p.tokens) == 2 - assert p.tokens[0].ttype == T.Comparison + assert p.tokens[0].ttype == T.Keyword assert isinstance(p.tokens[1], sql.Parenthesis) -def test_in_comparison(): - # issue566 - p = sqlparse.parse('a in (1, 2)')[0] - assert len(p.tokens) == 1 - assert isinstance(p.tokens[0], sql.Comparison) - assert len(p.tokens[0].tokens) == 5 - assert p.tokens[0].left.value == 'a' - assert p.tokens[0].right.value == '(1, 2)' - - def test_grouping_varchar(): p = sqlparse.parse('"text" Varchar(50) NOT NULL')[0] assert isinstance(p.tokens[2], sql.Function) |