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.
Projectandialbrecht/sqlparse
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
| 51 | 51 | return 1 | |
| 52 | 52 | return 0 | |
| 53 | 53 | ||
| 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 | + | ||
| 54 | 65 | # BEGIN and CASE/WHEN both end with END | |
| 55 | 66 | if unified == 'END': | |
| 56 | 67 | if not self._in_case: | |
| ⋯ | |||
| 111 | 122 | self.consume_ws = True | |
| 112 | 123 | elif ttype is T.Keyword and value.split()[0] == 'GO': | |
| 113 | 124 | 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, | |
| 115 | 126 | T.Comment.Multiline) | |
| 116 | 127 | and not (ttype is T.Keyword and value.upper() == 'BEGIN')): | |
| 117 | 128 | # Reset _seen_begin if we see a non-whitespace, non-comment | |
The check that tells the two apart
fail→pass·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
- 2026-07-25Fix get_real_name for names with more than two dotted parts (#332)
- 2026-07-22Fix function grouping skipped for lowercase 'as' in CREATE TABLE AS SELECT
- 2025-11-28StatementSplitter
- 2024-07-15StatementSplitter
- 2024-04-13Raise SQLParseError instead of RecursionError.
- 2024-04-13Fix Function.get_parameters(), add Funtion.get_window()