diff --git a/sqlparse/engine/statement_splitter.py b/sqlparse/engine/statement_splitter.py index bc57d170..5db9c9bf 100644 --- a/sqlparse/engine/statement_splitter.py +++ b/sqlparse/engine/statement_splitter.py @@ -182,7 +182,7 @@ def process(self, stream): # Split on semicolon if not inside a BEGIN...END block if self.level <= 0 and 'BEGIN' not in self._block_stack: self.consume_ws = True - elif ttype is T.Keyword and value.split()[0] == 'GO': + elif ttype is T.Keyword and value.upper().split()[0] == 'GO': self.consume_ws = True elif (ttype not in (T.Whitespace, T.Newline, T.Comment.Single, T.Comment.Multiline) diff --git a/tests/test_split.py b/tests/test_split.py index 92c3fefe..8a241c93 100644 --- a/tests/test_split.py +++ b/tests/test_split.py @@ -198,7 +198,12 @@ def test_split_strip_semicolon_procedure(load_file): @pytest.mark.parametrize('sql, num', [ ('USE foo;\nGO\nSELECT 1;\nGO', 4), ('SELECT * FROM foo;\nGO', 2), - ('USE foo;\nGO 2\nSELECT 1;', 3) + ('USE foo;\nGO 2\nSELECT 1;', 3), + # issue762: the batch separator is case-insensitive + ('USE foo;\ngo\nSELECT 1;\ngo', 4), + ('USE foo;\nGo\nSELECT 1;\nGo', 4), + ('SELECT * FROM foo;\ngo', 2), + ('USE foo;\ngo 2\nSELECT 1;', 3), ]) def test_split_go(sql, num): # issue762 stmts = sqlparse.split(sql)