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 1f1uuG-0000Fm-UR for pgsql-hackers@arkaria.postgresql.org; Fri, 30 Mar 2018 14:21:29 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1f1uuF-0004Ag-Mc for pgsql-hackers@arkaria.postgresql.org; Fri, 30 Mar 2018 14:21:27 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1f1uuF-0004AX-8h for pgsql-hackers@lists.postgresql.org; Fri, 30 Mar 2018 14:21:27 +0000 Received: from mail.postgrespro.ru ([93.174.131.138]) by makus.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1f1uuB-00065w-Ic for pgsql-hackers@lists.postgresql.org; Fri, 30 Mar 2018 14:21:25 +0000 Received: from localhost (localhost [127.0.0.1]) by mail.postgrespro.ru (Postfix) with ESMTP id 74BAA21C2A4D; Fri, 30 Mar 2018 17:21:20 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at postgrespro.ru X-Spam-Flag: NO X-Spam-Score: 0 X-Spam-Level: X-Spam-Status: No, score=x tagged_above=-99 required=4 WHITELISTED tests=[] autolearn=unavailable Received: from localhost (gw.postgrespro.ru [93.174.131.141]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mail.postgrespro.ru (Postfix) with ESMTPSA id 323E421C1CF6; Fri, 30 Mar 2018 17:21:20 +0300 (MSK) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=postgrespro.ru; s=mail; t=1522419680; bh=nf5ryd1M8rzkYvMal3YnsjDA3qFhGyKVFr3yQAgMUEI=; h=Date:From:To:Cc:Subject:References:In-Reply-To; b=IkMH9/s7gXWxmlb5QtlDpTIy1ZnMnIKVxK9qcJRSwrw2e1gt0oaVmsiweypqGFnaa +cTSl3XrNsXXFuXr2imnPUBnpAzDwLV0Xqbj8v4oyOnuhPXIk+ytNiUX3pHc7mduaz rZHu21uIrZCVp9ASJm4kDzuWzmXVWmWG4zybGI1k= Date: Fri, 30 Mar 2018 17:21:20 +0300 From: Aleksander Alekseev To: Teodor Sigaev Cc: Robert Haas , David Steele , Nikita Glukhov , Darafei Praliaskouski , Anastasia Lubennikova , PostgreSQL Hackers Subject: Re: Cast jsonb to numeric, int, float, bool Message-ID: <20180330142119.GA1411@e733.localdomain> References: <9c013081-5dc0-1b87-a559-a0c2d405727a@postgrespro.ru> <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> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="6TrnltStXW4iwmi0" Content-Disposition: inline In-Reply-To: <0250b45d-4a38-5453-cb5a-8fa9883da36b@sigaev.ru> User-Agent: Mutt/1.9.4 (2018-02-28) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --6TrnltStXW4iwmi0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hello Teodor, > For completeness it's possible to add direct cast from numeric/boolean ty= pes > 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. jso= nb > 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. --=20 Best regards, Aleksander Alekseev --6TrnltStXW4iwmi0 Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCAAdFiEECAokn0QZCoIHW4GpEEnCBLXCDtYFAlq+R90ACgkQEEnCBLXC DtbcMw//Wzl7jIQdfIKNpUVq+RMgVwOIPcUD5f0ck6RakCruAYnkCqedCNlLvIp2 Z8XyDzab1VrI6lwBIISaXk9ic85KJFW+4ruoBQmdxLRh3g2NHJRbiSep5LTJfwXe T58FJGDRgozOnT5yOyNzQIzJ7Ct81RZSA+6oJAu40PDMzRlDybxdmqxR2PkkI9aT fHUK4/bwO1dV339tcsMXbOlEjBzcSjDsq576vkjHCHKL/NUoKSldSBlpChoNXsRi hA0ShIOyScUXFqIWSdzVCOH+bTLzbLsZHyaPv5yBJt/IiNrXkVFeKYcMX0CBVRa6 BDQWAjcevpDtRWN9vodL//ozaR3QnSTwVV5EoMVtcsRROCwZ+/JehEq2Jpa2gNOe hQu5AQnrsHq2gy2QNYUJrhG4AYxJN0mJJ9RSWs1fCq66/7/7lpD42Bph0yWy+w3X Xf1AH7YSwdn3he9hhtzE0Y3YzwHTWD07Myi4OFeK1ig67MFBUyeonLjvwxT1BMfh zbQY/BepBMajB3zg6Q+Lh8LOasoI6Fh40yd4xvB2OwH2lkjkl6NURKMsZx/RDrAS 2g35WpTMv8aPadnDuUOQAeU2ho6gErZnqmXWvCKZCsgsN1cEZ/R3NmrTECDREFvT FXbN5mfxjrjeH9Geo5th/mkPW801sCMjVqtg60CYWUgvLFt1myQ= =ZOI1 -----END PGP SIGNATURE----- --6TrnltStXW4iwmi0--