Loading page...Загружаем страницу...正在加载页面...
AtlasRepo

n8n's Postgres Node Doesn't Send Parameters. My Dry-Run Did.

Описание и применение

В узле n8n для Postgres параметры запроса не передаются как привязанные переменные, из‑за чего при пустой строке возникает ошибка приведения типа. Проблема связана с тем, что pg-promise форматирует параметры в строку SQL, а не использует bind‑параметры. Перевод Query Parameters в один массив выражений устраняет ошибку, а также предотвращает смещение значений из‑за запятых.

Задача

The n8n Postgres node fails to send query parameters as bind variables, causing runtime errors when empty strings are passed.

Результат

The issue was caused by pg-promise formatting parameters into the SQL string, leading to early evaluation of constant casts and comma‑split parameter misalignment. Adjusting the Query Parameters to a single array expression resolved the problem.

Рабочий процесс

  • 1. Identify the failing query and test it in psql with PREPARE and EXECUTE. 2. Observe that n8n’s Postgres node uses pg-promise which formats parameters into the SQL string. 3. Reproduce the error locally with pg-promise’s format function. 4. Understand that $1::int is a runtime cast, but ''::int is a constant cast evaluated before CASE. 5. Note that commas in Query Parameters split values, shifting placeholders. 6. Modify the node to use a single array expression for Query Parameters. 7. Verify the query runs without error and returns the correct result.

Доказательства

The Postgres node runs on pg-promise, pinned at 11.9.1 in n8n 2.41.6, the latest stable release as I write this.

Источник

pg-promise has its own formatting engine, and its README says the engine is "used by default with all query methods, unless you opt out of it entirely via option pgFormatting."

Источник

Run that against the database and you get error 22P02, invalid input syntax for type integer: "".

Источник

The section on expression evaluation rules says it plainly: CASE "is not a cure-all," and it "does not prevent early evaluation of constant subexpressions."

Источник

Query Parameters is always one array expression.

Источник

  • Дата записи: 2026-10-05T07:10:47.779Z