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

From: Aleksander Alekseev <a(dot)alekseev(at)postgrespro(dot)ru>
To: Teodor Sigaev <teodor(at)sigaev(dot)ru>
Cc: Robert Haas <robertmhaas(at)gmail(dot)com>, David Steele <david(at)pgmasters(dot)net>, 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>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Cast jsonb to numeric, int, float, bool
Date: 2018-03-30 14:21:20
Message-ID: 20180330142119.GA1411@e733.localdomain
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hello Teodor,

> For completeness it's possible to add direct cast from numeric/boolean types
> to jsonb. Then such casts will be mutual.

+1. I see no reason why we can't have int4 -> jsonb or bool -> jsonb
casts.

> Agree, something like "could not convert jsonb value to boolean type. jsonb
> value must be scalar boolean type"?

I checked what error messages are used currently:

```
# select 123::int4::jsonb;
ERROR: cannot cast type integer to jsonb
LINE 1: select 123::int4::jsonb;
```

I suggest to follow the same template, i.e. "cannot cast type jsonb to
bool", etc.

--
Best regards,
Aleksander Alekseev

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Aleksander Alekseev 2018-03-30 14:24:23 Re: Cast jsonb to numeric, int, float, bool
Previous Message Ashutosh Bapat 2018-03-30 14:06:22 Re: [HACKERS] advanced partition matching algorithm for partition-wise join