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

From Aleksander Alekseev
Subject Re: Cast jsonb to numeric, int, float, bool
Date
Msg-id 20180330142119.GA1411@e733.localdomain
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  (Aleksander Alekseev <a.alekseev@postgrespro.ru>)
List 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

Attachment

pgsql-hackers by date:

Previous
From: Ashutosh Bapat
Date:
Subject: Re: [HACKERS] advanced partition matching algorithm forpartition-wise join
Next
From: Aleksander Alekseev
Date:
Subject: Re: Cast jsonb to numeric, int, float, bool