One function

StatementSplitter in andialbrecht/sqlparse

The author described this change as Fix splitting of BEGIN TRANSACTION statements (fixes #826).. It counts as a record because the check below fails on the code as it stood at acd8e5817 and passes on 5ca50a2ee, with nothing else changed between the two runs.

Fix saved2025-11-29
Sharing licenceBSD-3-Clause · LICENSE
Change size+12 1

What the code was meant to do, written into the code itself as a docstring

Filter that split stream at individual statements

The change

5151 return 1
5252 return 0
5353
54+ # Issue826: If we see a transaction keyword after BEGIN,
55+ # it's a transaction statement, not a block.
56+ if self._seen_begin and \
57+ (ttype is T.Keyword or ttype is T.Name) and \
58+ unified in ('TRANSACTION', 'WORK', 'TRAN',
59+ 'DISTRIBUTED', 'DEFERRED',
60+ 'IMMEDIATE', 'EXCLUSIVE'):
61+ self._begin_depth = max(0, self._begin_depth - 1)
62+ self._seen_begin = False
63+ return 0
64+
5465 # BEGIN and CASE/WHEN both end with END
5566 if unified == 'END':
5667 if not self._in_case:
111122 self.consume_ws = True
112123 elif ttype is T.Keyword and value.split()[0] == 'GO':
113124 self.consume_ws = True
114- elif (ttype not in (T.Whitespace, T.Comment.Single,
125+ elif (ttype not in (T.Whitespace, T.Newline, T.Comment.Single,
115126 T.Comment.Multiline)
116127 and not (ttype is T.Keyword and value.upper() == 'BEGIN')):
117128 # Reset _seen_begin if we see a non-whitespace, non-comment

The check that tells the two apart

failpass·tests/test_split.py::test_split_begin_transaction

Check file tests/test_split.py, taken without changes from the fix and copied onto the older code, so the exact same check runs against both versions.

Origin and history

The code before itacd8e5817b5be5f9b9a7b159c1bacc45179f4e44
Broken version dated2025-11-28
Modulesqlparse.engine.statement_splitter
Units changedStatementSplitter
Fingerprintdc83b6c74d2079a5
Checked2026-08-18 by goldset/0.1

Every field above is generated by our program. None of it is written by hand.

Other bugs found in andialbrecht/sqlparse