Skip to content

fix(mysql): format FOR UPDATE as a clause - #1006

Closed
mkantautas wants to merge 1 commit into
sql-formatter-org:masterfrom
mkantautas:fix-mysql-for-update-clause
Closed

mkantautas wants to merge 1 commit into
sql-formatter-org:masterfrom
mkantautas:fix-mysql-for-update-clause

Conversation

@mkantautas

Copy link
Copy Markdown

Fixes #1005

In the MySQL dialect, FOR UPDATE was not a reserved clause, so UPDATE was formatted as the start of a new clause:

WHERE
  id = ? FOR
UPDATE;

This adds FOR UPDATE to the MySQL reserved clauses, as PostgreSQL and PL/SQL already do, so the output becomes:

WHERE
  id = ?
FOR UPDATE;

The new test in test/mysql.test.ts covers FOR UPDATE and FOR UPDATE SKIP LOCKED; it fails without the change.

@nene

nene commented Oct 29, 2026

Copy link
Copy Markdown
Collaborator

I'm adopting a new policy for this repository: no AI-generated contributions. I don't care how good they are.

This is to preserve my sanity.

@nene nene closed this Oct 29, 2026
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.

[FORMATTING] MySQL: FOR UPDATE is split into FOR / UPDATE across lines

2 participants