Reputation: 79390
Getting this on postgres:
syntax error at or near ""user""
For the following:
insert into "user" ("id", "email") values ('1', '[email protected]') on conflict do update "user" set "id" = '1', "email" = '[email protected]'
Been playing with it for a while, not sure where the syntax error is. Thank you for your help.
Upvotes: 0
Views: 160
Reputation: 22520
Apparently, you can't specify the table name in the ON CONFLICT UPDATE SET
clause. The following seems to work:
insert into "user" ("id", "email") values ('1', '[email protected]')
on conflict do update set "id" = '1', "email" = '[email protected]'
The syntax here:
....
DO UPDATE SET { column_name = { expression | DEFAULT } |
( column_name [, ...] ) = ( { expression | DEFAULT } [, ...] ) |
( column_name [, ...] ) = ( sub-SELECT )
} [, ...]
[ WHERE condition ]
Upvotes: 2