Repository navigation
Don't flag a safe UPDATE as destructive when it starts with a comment - #2440
Merged
rolandwalker merged 1 commit intoNov 16, 2026
Merged
Conversation
sqlparse's strip_comments leaves the space after a leading /* ... */ comment, so the first token of the cleaned query was whitespace and query_is_single_table_update() returned False.
Contributor
|
Nice catch! Thanks! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
With
destructive_warningincludingupdate, this asks for confirmation:while the same statement without the comment, or with the comment written as
/* c */UPDATEor-- con its own line, runs without a prompt.query_is_single_table_update()runssqlparse.format(query, strip_comments=True)first. For a leading block comment followed by a space that leaves" UPDATE t SET ...", sostatement[0]is the whitespace token and the function returns False. I strip the cleaned query before parsing.I added the leading-comment case to
test_query_is_single_table_updateand a newtest_is_destructive_update_with_where_clause_and_leading_comment. Both fail on main and pass with the fix;test_sql_utils.py(176 tests) and the execute/batch/interactive_utils tests pass.Checklist
changelog.mdfile.mycli/AUTHORS.txtfile (or it's already there).