Repository navigation
Check every statement for the destructive warning - #2390
Merged
rolandwalker merged 1 commit intoOct 26, 2026
Merged
Conversation
is_destructive() returned False as soon as it saw a single-table UPDATE with a WHERE clause, so any later statement in the same input was never checked. "UPDATE t SET x = 1 WHERE id = 1; DROP DATABASE prod" skipped the confirmation prompt. Skip the safe UPDATE and keep checking the remaining statements instead.
Contributor
|
Much appreciated! |
Contributor
|
Going out now in release https://github.com/dbcli/mycli/releases/tag/v2.30.2 . |
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
is_destructive()stops at the first single-tableUPDATE ... WHEREand returnsFalse, so the statements after it are never checked. Runningat the prompt (or with
--execute/batch mode and--warn-batch) runs theDROP DATABASEwithout the destructive-warning confirmation. The same happens forUPDATE ... WHERE ...; UPDATE t SET x = 2;, where the second update has noWHERE.The fix replaces the early
return Falsewithcontinue, so a safeUPDATEis skipped and the loop keeps checking the rest of the input. The function still returnsFalseonly when no statement matches.Added two tests in
test_sql_utils.py(safeUPDATEfollowed byDROP DATABASE, and safeUPDATEfollowed by anUPDATEwithoutWHERE). Both fail onmainand pass with this change; the rest oftest_sql_utils.pystill passes.Checklist
changelog.mdfile.mycli/AUTHORS.txtfile (or it's already there).