The following bug has been logged on the website:
Bug reference:      13961
Logged by:          Pravin Carvalho
Email address:      pravin@gida.in
PostgreSQL version: 9.5.1
Operating system:   All
Description:
If the new_value is null, JSONB_SET evaluates to null. This is not mentioned
in the documentation and intuitively I would expect this set the value of
the key at the specified path as null.
eg. SELECT jsonb_set('{"f1":1,"f2":2}', '{f2}',null);
I was using JSONB_SET to update a JSONB column where the new_value was the
result of the query and this could have led to loss of data.