diff options
author | Corey Zumar <corey.zumar@databricks.com> | 2019-12-24 17:25:45 -0800 |
---|---|---|
committer | Andi Albrecht <albrecht.andi@gmail.com> | 2020-01-16 09:19:34 +0100 |
commit | 6f72de13a3db480ed2909965b6e8cd02ac7fdf7e (patch) | |
tree | 2d6c081d1aae03aaca771466052d5a4e4ed731d7 | |
parent | 667aee971aedfca140be8c553f683d831adfc927 (diff) | |
download | sqlparse-6f72de13a3db480ed2909965b6e8cd02ac7fdf7e.tar.gz |
Add first test case
-rw-r--r-- | sqlparse/keywords.py | 2 | ||||
-rw-r--r-- | tests/test_grouping.py | 5 |
2 files changed, 4 insertions, 3 deletions
diff --git a/sqlparse/keywords.py b/sqlparse/keywords.py index 624650c..ad37c89 100644 --- a/sqlparse/keywords.py +++ b/sqlparse/keywords.py @@ -89,7 +89,7 @@ SQL_REGEX = { r'(EXPLODE|INLINE|PARSE_URL_TUPLE|POSEXPLODE|STACK)\b', tokens.Keyword), (r"(AT|WITH')\s+TIME\s+ZONE\s+'[^']+'", tokens.Keyword.TZCast), - (r'(LIKE|ILIKE)\b', tokens.Operator.Comparison), + (r'(NOT\s)?(LIKE|ILIKE)\b', tokens.Operator.Comparison), (r'[0-9_A-ZÀ-Ü][_$#\w]*', is_keyword), (r'[;:()\[\],\.]', tokens.Punctuation), (r'[<>=~!]+', tokens.Operator.Comparison), diff --git a/tests/test_grouping.py b/tests/test_grouping.py index 710fd15..5828e08 100644 --- a/tests/test_grouping.py +++ b/tests/test_grouping.py @@ -472,9 +472,10 @@ def test_comparison_with_parenthesis(): assert comp.right.ttype is T.Number.Integer -def test_comparison_with_strings(): +@pytest.mark.parametrize('operator', ['LIKE', 'NOT LIKE', 'ILIKE', 'NOT ILIKE']) +def test_comparison_with_strings(operator): # issue148 - p = sqlparse.parse("foo = 'bar'")[0] + p = sqlparse.parse("foo {0} 'bar'".format(operator))[0] assert len(p.tokens) == 1 assert isinstance(p.tokens[0], sql.Comparison) assert p.tokens[0].right.value == "'bar'" |