pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Aleksander Alekseev <a.alekseev@postgrespro.ru>
To: Teodor Sigaev <teodor@sigaev.ru>
Cc: Robert Haas <robertmhaas@gmail.com>
Cc: David Steele <david@pgmasters.net>
Cc: Nikita Glukhov <n.gluhov@postgrespro.ru>
Cc: Darafei Praliaskouski <me@komzpa.net>
Cc: Anastasia Lubennikova <a.lubennikova@postgrespro.ru>
Cc: PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Subject: Re: Cast jsonb to numeric, int, float, bool
Date: Fri, 30 Mar 2018 17:21:20 +0300
Message-ID: <20180330142119.GA1411@e733.localdomain> (raw)
In-Reply-To: <0250b45d-4a38-5453-cb5a-8fa9883da36b@sigaev.ru>
References: <9c013081-5dc0-1b87-a559-a0c2d405727a@postgrespro.ru>
	<151985418868.6915.17223208131889314092.pgcf@coridan.postgresql.org>
	<76b000ae-94d1-cd8f-a2e0-e536096469b0@postgrespro.ru>
	<d75ed4fe-574b-41c7-080f-ed662fa5d9ba@pgmasters.net>
	<20180327145337.GA20311@e733.localdomain>
	<ca0bdf99-98a5-3a44-3f49-13941e0634ca@sigaev.ru>
	<912e1a07-90a9-ad97-bc70-d71ec0f6f073@sigaev.ru>
	<be43822f-7fd2-c5c2-8435-6a896d1ed46c@sigaev.ru>
	<CA+Tgmob08StTV9yu04D0idRFNMh+UoyKax5Otvrix7rEZC8rMw@mail.gmail.com>
	<0250b45d-4a38-5453-cb5a-8fa9883da36b@sigaev.ru>

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

Attachments:

  signature.asc (application/pgp-signature, 832B) download

view thread (31+ messages)  latest in thread

Message-ID: <20180330142119.GA1411@e733.localdomain>
Permalink:  ../20180330142119.GA1411@e733.localdomain/
Also on:    postgresql.org/message-id/20180330142119.GA1411@e733.localdomain

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-hackers@postgresql.org
  Cc: a.alekseev@postgrespro.ru, teodor@sigaev.ru, robertmhaas@gmail.com, david@pgmasters.net, n.gluhov@postgrespro.ru, me@komzpa.net, a.lubennikova@postgrespro.ru, pgsql-hackers@lists.postgresql.org
  Subject: Re: Cast jsonb to numeric, int, float, bool
  In-Reply-To: <20180330142119.GA1411@e733.localdomain>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox