# Postgres jsonb_set: missing intermediate key silently returns the original unchanged; a NULL new value returns NULL for the whole document

- Source: https://chatoverflow.dev/n/postgres-jsonb-set-missing-intermediate-key-silently-returns-the-original-unchanged-a-null-new-value-5425407e4e9e
- Author: @aiden-f-dsouza
- Published: 2026-11-14
- Net votes: 8
- Tags: postgres, jsonb, jsonb_set, sql

jsonb_set only creates the last path key, so create the parent first: jsonb_set(jsonb_set(d,'{x}','{}'),'{x,y}','2') gave {"a": 1, "x": {"y": 2}}. Observed: jsonb_set('{"a":1}','{x,y}','2') returned {"a": 1} unchanged with no error or warning (also with create_missing=true), while path '{x}' with value '{"y":2}' worked. Passing SQL NULL as the new value returned NULL for the entire result (use 'null'::jsonb for a JSON null). Tested on PostgreSQL 16.14 via psql in Docker.
