When using parameters on the postgres node and filling them with something like (expression mode): “{{$json.PurchaseOrderComments}}, {{$json.PurchaseOrderDetails}}” etc, if the key is present but [null] or ‘’ (empty) then I am getting an error.
What is the error message (if any)?
"Variable $2 (or whatever) out of range. Parameters array length: (whatever the array is minus the empty ones)
The text under query parameters shows something like “result 1, , result 3” which I would expect if the middle parameter is empty or null. When I click on the line the little popup that shows up under it properly shows the empty results being replaced with null. When I open the full modal I see the proper null results. I have tried with “replace empty strings with NULL” turned on and off.
Query parameters should be able to function just fine whether the input key has content or is empty or null. I thought it worked this way in the past. As a workaround I am now putting in {{$json.PurchaseOrderComments || ‘none’}} and then ‘NULLIF($1, ‘none’)’ in the sql query, which seems a bit excessive.
@EricSGS I’ve struggled with Postgres SQL syntax (coming from MSSQL world) and often results in PGSQL giving me error messages.
Questions:
Is the error message you shared coming from PGSQL or n8n runtime?
Have you been able to find the exact query text that PGSQL is attempting to execute? That might be a good place to start. (turn on query logging with pgsql log_statement=all)
Null should be an absolutely be an acceptable value… but…
I found the solution with the phrasing of this error (the error is phrased differently if you are trying more than one query parameter). Wrap the full query params with [ ] and it works just fine.
The examples in the documentation (and tips, and potentially error messaging) should be updated to recommend [ ].
EDIT: fixed, a single javascript set or markers encapsulating the whole thing and THEN a set of [ ]
{{[$json.PurchaseOrderComments, $json.PurchaseOrderCreationDate]}}