diff options
| author | Andi Albrecht <albrecht.andi@gmail.com> | 2016-09-26 13:03:42 +0200 |
|---|---|---|
| committer | Andi Albrecht <albrecht.andi@gmail.com> | 2016-09-26 13:03:42 +0200 |
| commit | ee2cbfea194fac4f2bbfe526fe2c3bdb856aed0b (patch) | |
| tree | 9f88e39f29c47093c558466c8a9e2193c4f7ec84 | |
| parent | e413b7867b8599fac2d4e9f6bb19a668fecb7e02 (diff) | |
| download | sqlparse-ee2cbfea194fac4f2bbfe526fe2c3bdb856aed0b.tar.gz | |
Fix parsing of UNION ALL (fixes #294).
| -rw-r--r-- | CHANGELOG | 1 | ||||
| -rw-r--r-- | sqlparse/keywords.py | 1 | ||||
| -rw-r--r-- | tests/test_tokenize.py | 6 |
3 files changed, 8 insertions, 0 deletions
@@ -10,6 +10,7 @@ Bug Fixes * Fix parsing of incomplete AS (issue284, by vmuriart). * Fix parsing of Oracle names containing dollars (issue291). +* Fix parsing of UNION ALL (issue294). Internal Changes diff --git a/sqlparse/keywords.py b/sqlparse/keywords.py index 3336831..48d37f0 100644 --- a/sqlparse/keywords.py +++ b/sqlparse/keywords.py @@ -73,6 +73,7 @@ SQL_REGEX = { r'|(CROSS\s+|NATURAL\s+)?)?JOIN\b', tokens.Keyword), (r'END(\s+IF|\s+LOOP|\s+WHILE)?\b', tokens.Keyword), (r'NOT\s+NULL\b', tokens.Keyword), + (r'UNION\s+ALL\b', tokens.Keyword), (r'CREATE(\s+OR\s+REPLACE)?\b', tokens.Keyword.DDL), (r'DOUBLE\s+PRECISION\b', tokens.Name.Builtin), diff --git a/tests/test_tokenize.py b/tests/test_tokenize.py index 22cb90f..b548541 100644 --- a/tests/test_tokenize.py +++ b/tests/test_tokenize.py @@ -157,6 +157,12 @@ def test_parse_join(expr): assert p.tokens[0].ttype is T.Keyword +def test_parse_union(): # issue294 + p = sqlparse.parse('UNION ALL')[0] + assert len(p.tokens) == 1 + assert p.tokens[0].ttype is T.Keyword + + @pytest.mark.parametrize('s', ['END IF', 'END IF', 'END\t\nIF', 'END LOOP', 'END LOOP', 'END\t\nLOOP']) def test_parse_endifloop(s): |
