Repository navigation
fix(destructive-sql): detect UPDATE without WHERE for t * and ONLY (t) targets - #575
Closed
flipslidersand wants to merge 1 commit into
Closed
flipslidersand wants to merge 1 commit into
flipslidersand wants to merge 1 commit into
Conversation
… (t)` targets The UPDATE-without-WHERE classifier only accepted `t` and `ONLY t`, so `UPDATE films* SET ...` and `UPDATE ONLY (films) SET ...` ran without a confirmation prompt. Accept all four target spellings PostgreSQL allows, including schema-qualified names and aliases. Fixes supabase#564 Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Author
3 tasks
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.
What kind of change does this PR introduce?
Bug fix.
What is the current behavior?
Fixes #564.
execute_sqlandapply_migrationask for confirmation before anUPDATEwithoutWHERE, but only when the target table is written asfilmsorONLY films. PostgreSQL accepts four spellings for the target of anUPDATE:films,films *,ONLY filmsandONLY (films). The classifier (updateWithoutWhereRegexindestructive-sql.ts) only recognised the first and the third, soUPDATE films* SET ...andUPDATE ONLY (films) SET ...ran without a prompt and changed every row.What is the new behavior?
All four spellings are classified the same way. Schema-qualified targets (
public.films*,ONLY (public.films) f) and aliases (films * AS f) are covered too. Statements with aWHEREclause are classified as before.The change is limited to the regular expression that describes the
UPDATEtarget. Statement splitting, literal masking andEXPLAINhandling are untouched.How to Review
Classifier
packages/mcp-server-supabase/src/tools/destructive-sql.tsupdateTargetplus the newupdateWithoutWhereRegexaccept the four target spellings, and that the rest of the pattern (optional alias,SET, theWHERElookahead) is the same as before.Tests
packages/mcp-server-supabase/src/tools/destructive-sql.test.tstest.eachinisUpdateWithoutWherelists the six spellings from the issue, including the plainfilmsandONLY filmsbaselines.Verification
UPDATE public.films* ...,UPDATE films * AS f ...,UPDATE ONLY (films) ...andUPDATE ONLY (public.films) f .... These are the spellings reported in execute_sql does not ask for confirmation for UPDATEs without WHERE that use inheritance syntax (films*, ONLY (films)) #564.CI=1 pnpm exec vitest run --project unit src/tools/destructive-sql.test.tsreports 149 passed, 0 failed.Not covered:
execute_sql/apply_migrationwith a form-capable client; only the unit tests for the classifier.tscfor the whole workspace because@supabase/mcp-utilswas not built in my checkout.AI assistance
This change was prepared with AI assistance (Claude Code). The tests listed above were run in that session.