I am trying to implement an upsert for a Postgres node, using the following code:
INSERT INTO return VALUES ({{$node["Map Keys RETURNS"].json["id"]}},'{{$node["Map Keys RETURNS"].json["rrn"]}}',{{$node["Map Keys RETURNS"].json["order_id"]}},{{$node["Map Keys RETURNS"].json["order_item_id"]}},{{$node["Map Keys RETURNS"].json["product_id"]}},'{{$node["Map Keys RETURNS"].json["date_created"]}}','{{$node["Map Keys RETURNS"].json["status"]}}')
ON CONFLICT (id) DO
UPDATE SET rrn = EXCLUDED.rrn, order_id = EXCLUDED.order_id, order_item_id = EXCLUDED.order_item_id, product_id = EXCLUDED.product_id, date_created = EXCLUDED.date_created, status = EXCLUDED.status;
But, on execution, I keep getting the following exception:
error: syntax error at or near ","
at Connection.parseE (/usr/local/lib/node_modules/n8n/node_modules/pg-promise/node_modules/pg/lib/connection.js:604:11)
at Connection.parseMessage (/usr/local/lib/node_modules/n8n/node_modules/pg-promise/node_modules/pg/lib/connection.js:401:19)
at Socket.<anonymous> (/usr/local/lib/node_modules/n8n/node_modules/pg-promise/node_modules/pg/lib/connection.js:121:22)
at Socket.emit (events.js:310:20)
at addChunk (_stream_readable.js:286:12)
at readableAddChunk (_stream_readable.js:268:9)
at Socket.Readable.push (_stream_readable.js:209:10)
at TCP.onStreamRead (internal/stream_base_commons.js:186:23)
Pasting the rendered query result into a SQL client, executes the query correctly.
Also, if I change the Operation type to an INSERT, the node executes successfully - but, then I cannot upsert.