Whole file

andialbrecht/sqlparse

The author described this change as Fix issue with strip_comments causing a syntax error (fixes #425). It counts as a record because the check below fails on the code as it stood at 488505f6c and passes on 6c7b89cc8, with nothing else changed between the two runs.

Fix saved2018-11-21
Sharing licenceBSD-3-Clause · LICENSE
Change size+7 0

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

Fix issue with strip_comments causing a syntax error (fixes #425)

The change

2626 if (prev_ is None or next_ is None or
2727 prev_.is_whitespace or prev_.match(T.Punctuation, '(') or
2828 next_.is_whitespace or next_.match(T.Punctuation, ')')):
29+ # Insert a whitespace to ensure the following SQL produces
30+ # a valid SQL. For example:
31+ #
32+ # Before: select a--comment\nfrom foo
33+ # After: select a from foo
34+ if prev_ is not None and next_ is None:
35+ tlist.tokens.insert(tidx, sql.Token(T.Whitespace, ' '))
2936 tlist.tokens.remove(token)
3037 else:
3138 tlist.tokens[tidx] = sql.Token(T.Whitespace, ' ')

The check that tells the two apart

failpass·tests/test_format.py::TestFormat::test_strip_comments_single

Check file tests/test_format.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 it488505f6c448e7eb0e4a1915bdc5b6130d44a68a
Broken version dated2018-08-28
Modulesqlparse.filters.others
Units changedStripCommentsFilter
Fingerprint8776fb0f856e2d6a
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