Postgresql node - Execute query - Behavior when using variables

Describe the problem/error/question

Hey team :wave:

I have noticed few times a little issue with the Postgres “Execute a SQL query” node.
When updating a query like this:

=INSERT INTO table (id, name, description)
VALUES ({{ $json["id"] }}, '{{ $json["name"] }}', '{{ $json["description"] }}');

The Query view is sometimes behaving in a weird way.

If I modify part of it, like adding or removing a quote ’ or renaming a value, it keeps coming back or even back to 2 other changes when I click outside the edit box. I can’t be update the query directly from the UI unless if I recreate it from scratch of if I modify the json node. I’ve tried refresh, ctrl+shift+r, restart, but nothing fixed it.

Unfortunately, I still have many workflows where I still need to update the queries as I can’t use “Postgres - Insert or Update”, especially when using Postgres node for connecting to Clickhouse DBs.

What is the error message (if any)?

From the Chrome console, I keep seeing this:

Uncaught RangeError: Position 174 is out of range for changeset of length 143
    at F.mapPos (codemirror-lang-sql-feLn5IS9.js:4:5613)
    at tn.map (codemirror-lang-sql-feLn5IS9.js:5:2540)
    at R.map (codemirror-lang-sql-feLn5IS9.js:5:4358)
    at te.update [as updateF] (index-sBP6yvIP.js:134:30249)
    at Object.update (codemirror-lang-sql-feLn5IS9.js:4:17093)
    at D.computeSlot (codemirror-lang-sql-feLn5IS9.js:4:25747)
    at At (codemirror-lang-sql-feLn5IS9.js:4:19914)
    at new D (codemirror-lang-sql-feLn5IS9.js:4:24938)
    at D.applyTransaction (codemirror-lang-sql-feLn5IS9.js:4:25717)
    at get state (codemirror-lang-sql-feLn5IS9.js:4:21370)

Let me know if you need any other information.

Information on your n8n setup

  • n8n version: 1.29.1 (but I think it started around the 1.27.0)
  • Database (default: SQLite): SQLite
  • n8n EXECUTIONS_PROCESS setting (default: own, main): own
  • Running n8n via (Docker, npm, n8n cloud, desktop app): Docker
  • Browser: Chrome 122.0.6261.69 (64-bit) on Ubuntu 22.04.4 LTS

Hey @Romuald_BARON,

I have made a quick workflow to reproduce this which can be found below but I am not able to reproduce anything odd happening. Would you be able to try the below flow and see if you can reproduce it with that it could be that it is linked to the content you are using but we can expand to that next if needed.

If you have some screenshots or a video of the issue that would be a big help as well.