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

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

说明与用途

n8n 的 Postgres 节点未将查询参数作为绑定变量发送,导致传入空字符串时出现类型转换错误。问题源于 pg-promise 将参数格式化为 SQL 字符串。将 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