Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1f1vqa-000405-Dt for pgsql-hackers@arkaria.postgresql.org; Fri, 30 Mar 2018 15:21:44 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1f1vqY-0005mN-TT for pgsql-hackers@arkaria.postgresql.org; Fri, 30 Mar 2018 15:21:42 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1f1vqY-0005lz-Mf for pgsql-hackers@lists.postgresql.org; Fri, 30 Mar 2018 15:21:42 +0000 Received: from ping.uio.no ([2001:700:100:570::196]) by magus.postgresql.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1f1vqV-0001Ra-M2 for pgsql-hackers@lists.postgresql.org; Fri, 30 Mar 2018 15:21:41 +0000 Received: from [2001:700:100:570::211] (helo=dalvik.ping.uio.no ident=Debian-exim) by ping.uio.no with esmtp (Exim 4.72 #1 (Debian)) id 1f1vqJ-0000iQ-1C; Fri, 30 Mar 2018 17:21:30 +0200 Received: from ilmari by dalvik.ping.uio.no with local (Exim 4.84_2) (envelope-from ) id 1f1vqI-0001Po-T9; Fri, 30 Mar 2018 17:21:26 +0200 From: ilmari@ilmari.org (Dagfinn Ilmari =?utf-8?Q?Manns=C3=A5ker?=) To: Aleksander Alekseev Cc: Teodor Sigaev , Robert Haas , David Steele , Nikita Glukhov , Darafei Praliaskouski , Anastasia Lubennikova , PostgreSQL Hackers Subject: Re: Cast jsonb to numeric, int, float, bool References: <151985418868.6915.17223208131889314092.pgcf@coridan.postgresql.org> <76b000ae-94d1-cd8f-a2e0-e536096469b0@postgrespro.ru> <20180327145337.GA20311@e733.localdomain> <912e1a07-90a9-ad97-bc70-d71ec0f6f073@sigaev.ru> <0250b45d-4a38-5453-cb5a-8fa9883da36b@sigaev.ru> <20180330142119.GA1411@e733.localdomain> <20180330142423.GB1411@e733.localdomain> Mail-Copies-To: nobody Date: Fri, 30 Mar 2018 16:21:26 +0100 In-Reply-To: <20180330142423.GB1411@e733.localdomain> (Aleksander Alekseev's message of "Fri, 30 Mar 2018 17:24:23 +0300") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Exiscan-Spam-Score: -3.7 (---) X-Exiscan-Spam-Report: SpamAssassin 3.3.1 (2010-03-16) on pike.ping.uio.no Score Rule * -5.0 PING_UIO_MAIL_IS_INTERNAL Message has never been outside * 129.240.0.0/16 or 193.157.115.0/24 * 1.3 RDNS_NONE Delivered to internal network by a host with no rDNS List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Aleksander Alekseev 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