Maciek Sakrejda <mac...@pganalyze.com> writes: > Oddly, it looks like you only get a null if you use the '->>' > operator. With '->' and a subsequent cast to text, you get the string > "null":
> maciek=# select (('{"a":null}'::jsonb)->'a')::text; > text > ------ > null > (1 row) > Is that expected? I think what is happening there is you're getting the fallback "cast via I/O" behavior. There's no jsonb->text cast function in the catalogs. Perhaps it's worth adding one, so that it can be made to behave similarly to the casts to other types. However, that would be a compatibility break for a case that doesn't fail today, so it might be a harder sell than changing cases that do fail. I'm mildly in favor of doing it, but somebody else might think differently. regards, tom lane