Why does select jsonb_set('{"foo": 1}'::jsonb, '{bar}', to_jsonb(null::int), true) return NULL when all it should do is to add a second key? I would expect {"foo": 1, "bar": null} or no change at all to the original JSON value, but not that the whole JSON is set to null. In the original case the new value to be set was the result of an expression, not a "hardcoded" null value. Thomas