File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -25,6 +25,8 @@ Bug Fixes
2525* Remove shebang from cli.py and remove executable flag (pr818).
2626* Fix strip_comments not removing all comments when input contains only
2727 comments (issue801, pr803 by stropysh).
28+ * Fix splitting statements with IF EXISTS/IF NOT EXISTS inside BEGIN...END
29+ blocks (issue812).
2830
2931
3032Release 0.5.3 (Dez 10, 2024)
Original file line number Diff line number Diff line change 7070 (r'((LEFT\s+|RIGHT\s+|FULL\s+)?(INNER\s+|OUTER\s+|STRAIGHT\s+)?'
7171 r'|(CROSS\s+|NATURAL\s+)?)?JOIN\b' , tokens .Keyword ),
7272 (r'END(\s+IF|\s+LOOP|\s+WHILE)?\b' , tokens .Keyword ),
73+ (r'IF\s+(NOT\s+)?EXISTS\b' , tokens .Keyword ),
7374 (r'NOT\s+NULL\b' , tokens .Keyword ),
7475 (r'(ASC|DESC)(\s+NULLS\s+(FIRST|LAST))?\b' , tokens .Keyword .Order ),
7576 (r'(ASC|DESC)\b' , tokens .Keyword .Order ),
Original file line number Diff line number Diff line change @@ -208,3 +208,17 @@ def test_split_go(sql, num): # issue762
208208def test_split_multiple_case_in_begin (load_file ): # issue784
209209 stmts = sqlparse .split (load_file ('multiple_case_in_begin.sql' ))
210210 assert len (stmts ) == 1
211+
212+
213+ def test_split_if_exists_in_begin_end (): # issue812
214+ # IF EXISTS should not be confused with control flow IF
215+ sql = """CREATE TASK t1 AS
216+ BEGIN
217+ CREATE OR REPLACE TABLE temp1;
218+ DROP TABLE IF EXISTS temp1;
219+ END;
220+ EXECUTE TASK t1;"""
221+ stmts = sqlparse .split (sql )
222+ assert len (stmts ) == 2
223+ assert 'CREATE TASK' in stmts [0 ]
224+ assert 'EXECUTE TASK' in stmts [1 ]
You can’t perform that action at this time.
0 commit comments