Dear Support Team,
With `jsonb_set()`, when `new_value` is `NULL`, the function would **erase
the whole object**:
postgres=# SELECT jsonb_set('{"something":1}'::jsonb, '{language}', null,
true);
jsonb_set
-----------
(1 row)
This is really dangerous for it may lead to data loss. Imaging the `
new_value` argument being a function which returns `NULL` values in some
cases.
The expected behavior is, perhaps, to convert an SQL `NULL` value to JSONB
null value: 'null'::jsonb
This way no data would be lost.
Or at the very least, this behavior should be documented.
Thank you in advance,
Mark