Re: Cast jsonb to numeric, int, float, bool - Mailing list pgsql-hackers

From Teodor Sigaev
Subject Re: Cast jsonb to numeric, int, float, bool
Date
Msg-id 912e1a07-90a9-ad97-bc70-d71ec0f6f073@sigaev.ru
Whole thread Raw
In response to Re: Cast jsonb to numeric, int, float, bool  (Teodor Sigaev <teodor@sigaev.ru>)
Responses Re: Cast jsonb to numeric, int, float, bool  (Teodor Sigaev <teodor@sigaev.ru>)
List pgsql-hackers
> I think, it should support from/to numeric/bool/text only. If we want to have 
> casts to from numeric to other numeric types then it should be full set (int2, 
> int4, int8, float4, float8).

I was too optimistic about casting to/from text. It already exists and it works 
by differ way from suggested  casts:

1) select '"foo"'::jsonb::text;  -> "foo"  // with ""
2) select '123'::jsonb::text;    -> 123
3) select '123'::jsonb::int4;    -> 123

Seems, sometime it would be desirable result in 1) as just
'foo' without "" decoration, but we cannot have 2 different explicit casts for 
the same types. So, I withdraw objections about text casting, but I still 
believe that we need one of two variants:
1) numeric/bool
2) bool, numeric/all variants of numeric types


-- 
Teodor Sigaev                                   E-mail: teodor@sigaev.ru
                                                    WWW: http://www.sigaev.ru/


pgsql-hackers by date:

Previous
From: Craig Ringer
Date:
Subject: Re: Proposal: http2 wire format
Next
From: Tatsuo Ishii
Date:
Subject: Re: Proposal: http2 wire format