Sorry, my bad on this last one. You cannot use to_jsonb to construct a json null. The only way, I think, to construct a json null scalar is with an explicit literal.
SELECT 'null'::jsonb;
The to_jsonb function always interprets a textual value passed to it as being the literal text and so the original query results in a json string whose content is "null"
Чтобы сделать работу с сайтом удобнее, мы используем cookie и аналитический сервис «Яндекс.Метрика». Продолжая пользоваться сайтом, вы соглашаетесь с их использованием.