UPSERT query in postgres

Describe the problem/error/question

Hello,
I have a little problem that I don’t understand.
In a Postgres node I use this query :

Share the output returned by the last node

erreur de syntaxe sur ou près de « s »
Failed query: INSERT INTO books (title, price)
VALUES ('Our Band Could Be Your Life: Scenes from the American Indie Underground, 1981-1991', '£57.25')
ON CONFLICT (title) DO NOTHING;

If I test the query in postgresql it works fine…
Any idea ?

Thanks

Information on your n8n setup

  • n8n version: 1.50.1
  • Database: PostgreSQL
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • Running n8n via: Docker
  • Operating system: Linux Debian 11

It looks like your topic is missing some important information. Could you provide the following if applicable.

  • n8n version:
  • Database (default: SQLite):
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • Running n8n via (Docker, npm, n8n cloud, desktop app):
  • Operating system:

@sd35 , indeed, there seems to be an issue with “Execute Query” operation (though I got a different error). This, however, could be overcome with “Insert” or “Insert or Update” operations (whichever is more suitable)

1 Like

I just tested the insert or update, it works very well. Thank you for the advice.

I’m trying to see if there is a bug here that we need to fix.
What was the books schema like?

I tried this and could not reproduce:

  1. create table books (title varchar primary key, price varchar);
  2. Execute the query from the error you shared

So far I have not been able to reproduce this error on the latest codebase.

here is the table :

CREATE TABLE books
(
    id    SMALLSERIAL UNIQUE ,
    title VARCHAR CONSTRAINT books_pk UNIQUE,
    price VARCHAR
);

Thanks. but still not able to reproduce in psql, or on n8n.


I don’t see any special characters, so perhaps we can rule out encoding issues :thinking:

Can you please check if switching over to parameters fixes this for you?

This method works :slight_smile:

Maybe the problem is the string?


And here it works :

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.