Re: Casting json (or jsonb) to real
| От | Tom Lane |
|---|---|
| Тема | Re: Casting json (or jsonb) to real |
| Дата | |
| Msg-id | 378261.1654044651@sss.pgh.pa.us обсуждение исходный текст |
| Ответ на | Casting json (or jsonb) to real (Wells Oliver <wells.oliver@gmail.com>) |
| Ответы |
Re: Casting json (or jsonb) to real
|
| Список | pgsql-admin |
Wells Oliver <wells.oliver@gmail.com> writes:
> When I know this value is a floating point value I would just like to cast
> SELECT value::real but you can't do that. You can do SELECT
> (jsonbcol->>'somekey')::real, but these columns just store a value.
Works for me, in v11 and up:
regression=# select '1.4531'::jsonb::real;
float4
--------
1.4531
(1 row)
In older versions you could do
regression=# select '1.4531'::jsonb::text::real;
float4
--------
1.4531
(1 row)
I fear that either one involves a conversion to text and back
under the hood :-(. Now, if you were casting to numeric,
that would be very cheap.
regards, tom lane
В списке pgsql-admin по дате отправления: