Skip to content

fix(destructive-sql): detect UPDATE without WHERE for t * and ONLY (t) targets - #575

Closed
flipslidersand wants to merge 1 commit into
supabase:mainfrom
flipslidersand:fix/update-target-spellings-564
Closed

flipslidersand wants to merge 1 commit into
supabase:mainfrom
flipslidersand:fix/update-target-spellings-564

Conversation

@flipslidersand

Copy link
Copy Markdown

What kind of change does this PR introduce?

Bug fix.

What is the current behavior?

Fixes #564.

execute_sql and apply_migration ask for confirmation before an UPDATE without WHERE, but only when the target table is written as films or ONLY films. PostgreSQL accepts four spellings for the target of an UPDATE: films, films *, ONLY films and ONLY (films). The classifier (updateWithoutWhereRegex in destructive-sql.ts) only recognised the first and the third, so UPDATE films* SET ... and UPDATE 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 a WHERE clause are classified as before.

The change is limited to the regular expression that describes the UPDATE target. Statement splitting, literal masking and EXPLAIN handling are untouched.

How to Review

  1. Classifier

    • packages/mcp-server-supabase/src/tools/destructive-sql.ts
    • Check that updateTarget plus the new updateWithoutWhereRegex accept the four target spellings, and that the rest of the pattern (optional alias, SET, the WHERE lookahead) is the same as before.
  2. Tests

    • packages/mcp-server-supabase/src/tools/destructive-sql.test.ts
    • The new test.each in isUpdateWithoutWhere lists the six spellings from the issue, including the plain films and ONLY films baselines.

Verification

Not covered:

  • I did not run the integration tests through execute_sql / apply_migration with a form-capable client; only the unit tests for the classifier.
  • I did not run tsc for the whole workspace because @supabase/mcp-utils was not built in my checkout.
  • I could not apply the repository's Prettier configuration in my checkout, so formatting is by hand to match the surrounding code; please let CI confirm.

AI assistance

This change was prepared with AI assistance (Claude Code). The tests listed above were run in that session.

… (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]>
@flipslidersand
flipslidersand requested a review from a team as a code owner November 18, 2026 12:53
@flipslidersand

Copy link
Copy Markdown
Author

Closing as a duplicate of #565, which fixes #564 and also covers the no-whitespace forms. I verified #565 locally against my test cases (see my review there).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

execute_sql does not ask for confirmation for UPDATEs without WHERE that use inheritance syntax (films*, ONLY (films))

1 participant