Re: Casts from jsonb to other types should cope with json null
| От | Tom Lane |
|---|---|
| Тема | Re: Casts from jsonb to other types should cope with json null |
| Дата | |
| Msg-id | 3858623.1722555871@sss.pgh.pa.us обсуждение |
| Ответ на | Re: Casts from jsonb to other types should cope with json null (Maciek Sakrejda <maciek@pganalyze.com>) |
| Ответы |
Casts from jsonb to other types should cope with json null
|
| Список | pgsql-hackers |
Maciek Sakrejda <maciek@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
В списке pgsql-hackers по дате отправления: