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

From: Teodor Sigaev <teodor(at)sigaev(dot)ru>
To: Aleksander Alekseev <a(dot)alekseev(at)postgrespro(dot)ru>, David Steele <david(at)pgmasters(dot)net>
Cc: Nikita Glukhov <n(dot)gluhov(at)postgrespro(dot)ru>, Darafei Praliaskouski <me(at)komzpa(dot)net>, Anastasia Lubennikova <a(dot)lubennikova(at)postgrespro(dot)ru>, pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: Cast jsonb to numeric, int, float, bool
Date: 2018-03-29 13:35:39
Message-ID: be43822f-7fd2-c5c2-8435-6a896d1ed46c@sigaev.ru
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Thanks for everyone, pushed with some editorization

Teodor Sigaev wrote:
>> 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(at)sigaev(dot)ru
WWW: http://www.sigaev.ru/

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tomas Vondra 2018-03-29 13:36:09 Re: [HACKERS] PATCH: multivariate histograms and MCV lists
Previous Message John Naylor 2018-03-29 13:33:09 Re: pgsql: Add documentation for the JIT feature.