Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/languages/mysql/mysql.formatter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ const reservedClauses = expandPhrases([
'ORDER BY',
'LIMIT',
'OFFSET',
'FOR UPDATE',
// Data manipulation
// - insert:
'INSERT [LOW_PRIORITY | DELAYED | HIGH_PRIORITY] [IGNORE] [INTO]',
Expand Down
27 changes: 27 additions & 0 deletions test/mysql.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,4 +114,31 @@ describe('MySqlFormatter', () => {
DROP DEFAULT;
`);
});

// Issue #1005
it('formats FOR UPDATE clause', () => {
expect(
format(`
SELECT * FROM users WHERE id = ? FOR UPDATE;
SELECT * FROM users WHERE id = ? FOR UPDATE SKIP LOCKED;
`)
).toBe(dedent`
SELECT
*
FROM
users
WHERE
id = ?
FOR UPDATE;

SELECT
*
FROM
users
WHERE
id = ?
FOR UPDATE
SKIP LOCKED;
`);
});
});