Skip to content

Commit ee2cbfe

Browse files
committed
Fix parsing of UNION ALL (fixes andialbrecht#294).
1 parent e413b78 commit ee2cbfe

3 files changed

Lines changed: 8 additions & 0 deletions

File tree

CHANGELOG

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ Bug Fixes
1010

1111
* Fix parsing of incomplete AS (issue284, by vmuriart).
1212
* Fix parsing of Oracle names containing dollars (issue291).
13+
* Fix parsing of UNION ALL (issue294).
1314

1415
Internal Changes
1516

sqlparse/keywords.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ def is_keyword(value):
7373
r'|(CROSS\s+|NATURAL\s+)?)?JOIN\b', tokens.Keyword),
7474
(r'END(\s+IF|\s+LOOP|\s+WHILE)?\b', tokens.Keyword),
7575
(r'NOT\s+NULL\b', tokens.Keyword),
76+
(r'UNION\s+ALL\b', tokens.Keyword),
7677
(r'CREATE(\s+OR\s+REPLACE)?\b', tokens.Keyword.DDL),
7778
(r'DOUBLE\s+PRECISION\b', tokens.Name.Builtin),
7879

tests/test_tokenize.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,12 @@ def test_parse_join(expr):
157157
assert p.tokens[0].ttype is T.Keyword
158158

159159

160+
def test_parse_union(): # issue294
161+
p = sqlparse.parse('UNION ALL')[0]
162+
assert len(p.tokens) == 1
163+
assert p.tokens[0].ttype is T.Keyword
164+
165+
160166
@pytest.mark.parametrize('s', ['END IF', 'END IF', 'END\t\nIF',
161167
'END LOOP', 'END LOOP', 'END\t\nLOOP'])
162168
def test_parse_endifloop(s):

0 commit comments

Comments
 (0)