Skip to content

Commit 381376c

Browse files
committed
Fix formatting of DO UPDATE in SQLite
Fixes #783
1 parent ac52357 commit 381376c

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

src/languages/sqlite/sqlite.formatter.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ const reservedJoins = expandPhrases([
6363
const reservedPhrases = expandPhrases([
6464
'ON {UPDATE | DELETE} [SET NULL | SET DEFAULT]',
6565
'{ROWS | RANGE | GROUPS} BETWEEN',
66+
'DO UPDATE',
6667
]);
6768

6869
export const sqlite: DialectOptions = {

test/sqlite.test.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,4 +65,17 @@ describe('SqliteFormatter', () => {
6565
(2, 'Dog');
6666
`);
6767
});
68+
69+
it('supports ON CONFLICT .. DO UPDATE syntax', () => {
70+
expect(format(`INSERT INTO tbl VALUES (1,'Leopard') ON CONFLICT DO UPDATE SET foo=1;`))
71+
.toBe(dedent`
72+
INSERT INTO
73+
tbl
74+
VALUES
75+
(1, 'Leopard')
76+
ON CONFLICT DO UPDATE
77+
SET
78+
foo = 1;
79+
`);
80+
});
6881
});

0 commit comments

Comments
 (0)