Set Empty Strings to Null Not working (Postgres Insert)

When inserting values into my Postgres database, I want to make sure if the value does not exist to then insert NULL instead.
→ I’m using the execute Query function, not INSERT because it will not allow me to cast types when inserting.

I’ve tried various different syntaxes, but either get a literal null, [empty] or undefined in my database even though I enabled replace empty strings with NULL (which it doesn’t do).

How can I make sure NULL gets inserted?


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:

hello @Nicole_Reiter

Is it not inserted properly? I see two fields have the proper type

Indeed the JSONB values will result in the currect null value, but the issue lies with the strings: group_ride_id, product_name, vehicle_qr_code.
When using NULL or null it will insert a literal, when using ‘’ it will result in empty.

Remove the single quotes around expressions.

Otherwise, it will result as a string like '\'\''

And I think type definitions won’t work there

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