From: | Wells Oliver <wells(dot)oliver(at)gmail(dot)com> |
---|---|
To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | pgsql-admin <pgsql-admin(at)postgresql(dot)org> |
Subject: | Re: Casting json (or jsonb) to real |
Date: | 2022-06-01 05:18:05 |
Message-ID: | CAOC+FBU6E394M6DGerpQD1Cv4t=te4tg6aCXTRWyeZ=RoHGM=g@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-admin |
Thanks, yeah, a lot of this stored by json.dumps(v) in python, so this will
allow me to update the column...
On Tue, May 31, 2022 at 6:18 PM Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> Wells Oliver <wells(dot)oliver(at)gmail(dot)com> writes:
> > Well, it's because the representation of the value is getting double
> > quoted, so it's
> > select '"1.453"'::real, which yields ERROR: cannot cast jsonb string to
> > type real.
>
> Oh ... that perhaps wasn't a great choice. But it looks like you could
> pretend the jsonb is a 1-element array, and do
>
> regression=# select ('"1.4531"'::jsonb->>0)::real;
> float4
> --------
> 1.4531
> (1 row)
>
> regards, tom lane
>
--
Wells Oliver
wells(dot)oliver(at)gmail(dot)com <wellsoliver(at)gmail(dot)com>
From | Date | Subject | |
---|---|---|---|
Next Message | Ron | 2022-06-02 06:17:16 | Re: how to calibrate the cost model parameters |
Previous Message | jian xu | 2022-06-01 02:20:59 | RE: how to calibrate the cost model parameters |