"Ivan E. Panchenko" <i.panchenko@postgrespro.ru> writes:
> Thanks for the workaround. Nevertheless, this behavior looks
> counter-intuitive, and I would vote for removing strictness from this
> function.
That would amount to assuming that SQL NULL and JSON 'null' are
interchangeable, which isn't the case elsewhere, and I'm not sure
we want it to be the case here. You can get the behavior you're
looking for with jsonb_set(..., COALESCE(fieldvalue, 'null')).
regards, tom lane