Re: Cast jsonb to numeric, int, float, bool

Поиск
Список
Период
Сортировка
От Darafei "Komяpa" Praliaskouski
Тема Re: Cast jsonb to numeric, int, float, bool
Дата
Msg-id CAC8Q8t++bOLPHqb1ui5Gg+w0vuhEoAg7B__1XpgT8xzi4MF2sA@mail.gmail.com
обсуждение исходный текст
Ответ на Re: Cast jsonb to numeric, int, float, bool  (Tom Lane <tgl@sss.pgh.pa.us>)
Ответы Re: Cast jsonb to numeric, int, float, bool  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-hackers
Hi Tom,
 
I hadn't been following this thread particularly, but I happened to notice
this bit, and I thought I'd better pop up to say No Way.  There will be
*no* implicit casts from json to any numeric type.  We have learned the
hard way that implicit cross-category casts are dangerous. 

I can see how a cast from text can be problematic, especially before the 'unknown' type.

But what would be the scenario of failure if we have an implicit cast from jsonb datatype (that likely already parsed the number internally, or knows it holds non-numeric value) to numeric, that returns an error if it's unable to perform the conversion?

The issue I think is that jsonb is special because it is in fact container. We've got dot-notation to unpack things from composite TYPE, and we've got arrow-notation to unpack things from jsonb, but such unpacking cannot take part in further computations, even though it's visually compatible.

What would be other options, if not implicit cast?

Darafei Praliaskouski, 
GIS Engineer / Juno Minsk

В списке pgsql-hackers по дате отправления:

Предыдущее
От: Peter Eisentraut
Дата:
Сообщение: Re: JIT compiling with LLVM v11
Следующее
От: Nikita Glukhov
Дата:
Сообщение: Re: Jsonb transform for pl/python