pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: ilmari@ilmari.org
To: Aleksander Alekseev <a.alekseev@postgrespro.ru>
Cc: 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 16:21:26 +0100
Message-ID: <d8j1sg1mvwp.fsf@dalvik.ping.uio.no> (raw)
In-Reply-To: <20180330142423.GB1411@e733.localdomain>
References: <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>
	<20180330142119.GA1411@e733.localdomain>
	<20180330142423.GB1411@e733.localdomain>

Aleksander Alekseev <a.alekseev@postgrespro.ru> writes:

> Hello Teodor,
>
>> > 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.
>
> On second thought this message is misleading. We can cat jsonb to bool,
> the problem is that the document is not a bool value.

How about "cannot cast jsonb $json_type to $sql_type" where $json_type
is the type inside the jsonb (e.g. string, number, boolean, array,
object)?

- ilmari
-- 
"The surreality of the universe tends towards a maximum" -- Skud's Law
"Never formulate a law or axiom that you're not prepared to live with
 the consequences of."                              -- Skud's Meta-Law




view thread (31+ messages)  latest in thread

Message-ID: <d8j1sg1mvwp.fsf@dalvik.ping.uio.no>
Permalink:  ../d8j1sg1mvwp.fsf@dalvik.ping.uio.no/
Also on:    postgresql.org/message-id/d8j1sg1mvwp.fsf@dalvik.ping.uio.no

 · 

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: ilmari@ilmari.org, 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: <d8j1sg1mvwp.fsf@dalvik.ping.uio.no>

* 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