Skip to content

Commit

Permalink
Fix formatting of DO UPDATE in SQLite
Browse files Browse the repository at this point in the history
Fixes #783
  • Loading branch information
nene committed Oct 8, 2024
1 parent ac52357 commit 381376c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/languages/sqlite/sqlite.formatter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ const reservedJoins = expandPhrases([
const reservedPhrases = expandPhrases([
'ON {UPDATE | DELETE} [SET NULL | SET DEFAULT]',
'{ROWS | RANGE | GROUPS} BETWEEN',
'DO UPDATE',
]);

export const sqlite: DialectOptions = {
Expand Down
13 changes: 13 additions & 0 deletions test/sqlite.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,17 @@ describe('SqliteFormatter', () => {
(2, 'Dog');
`);
});

it('supports ON CONFLICT .. DO UPDATE syntax', () => {
expect(format(`INSERT INTO tbl VALUES (1,'Leopard') ON CONFLICT DO UPDATE SET foo=1;`))
.toBe(dedent`
INSERT INTO
tbl
VALUES
(1, 'Leopard')
ON CONFLICT DO UPDATE
SET
foo = 1;
`);
});
});

0 comments on commit 381376c

Please sign in to comment.