mirror of https://github.com/AMT-Cheif/drift.git
Add parentheses around conflict target (#1704)
This commit is contained in:
parent
1854f8b522
commit
518fdce2e9
|
@ -1176,7 +1176,10 @@ class NodeSqlBuilder extends AstVisitor<void, void> {
|
|||
_keyword(TokenType.conflict);
|
||||
|
||||
if (e.onColumns != null) {
|
||||
symbol('(', spaceBefore: true);
|
||||
_join(e.onColumns!, ',');
|
||||
symbol(')', spaceAfter: true);
|
||||
|
||||
_where(e.where);
|
||||
}
|
||||
|
||||
|
|
|
@ -297,6 +297,16 @@ CREATE UNIQUE INDEX my_idx ON t1 (c1, c2, c3) WHERE c1 < c3;
|
|||
'INSERT OR REPLACE INTO foo DEFAULT VALUES ON CONFLICT DO NOTHING');
|
||||
});
|
||||
|
||||
test('upsert with conflict target', () {
|
||||
testFormat('INSERT INTO foo VALUES (1, 2, 3) ON CONFLICT (a, b, c) '
|
||||
'DO NOTHING;');
|
||||
});
|
||||
|
||||
test('upsert with conflict target and where', () {
|
||||
testFormat('INSERT INTO foo VALUES (1, 2, 3) '
|
||||
'ON CONFLICT (a, b, c) WHERE foo = bar DO NOTHING;');
|
||||
});
|
||||
|
||||
test('upsert - update', () {
|
||||
testFormat('INSERT INTO foo VALUES (1, 2, 3) '
|
||||
'ON CONFLICT DO UPDATE SET a = b, c = d WHERE d < a;');
|
||||
|
|
Loading…
Reference in New Issue