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 1fBhsS-0003Hg-Tq for pgsql-bugs@arkaria.postgresql.org; Thu, 26 Apr 2018 14:28:05 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1fBhsR-0003iZ-KT for pgsql-bugs@arkaria.postgresql.org; Thu, 26 Apr 2018 14:28:03 +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 1fBhiU-0008C5-Du for pgsql-bugs@lists.postgresql.org; Thu, 26 Apr 2018 14:17:46 +0000 Received: from [195.113.241.242] (helo=gw1-ntkdom.ntkcz.cz) by magus.postgresql.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1fBhiN-0005W3-TY for pgsql-bugs@postgresql.org; Thu, 26 Apr 2018 14:17:45 +0000 Received: from mattara.hosts.mordae.eu ([10.0.115.124]) by gw1-ntkdom.ntkcz.cz with ESMTP (TLS encrypted); Thu, 26 Apr 2018 16:19:04 +0200 To: pgsql-bugs@postgresql.org From: =?UTF-8?B?SmFuIEhhbWFsIER2b8WZw6Fr?= Subject: to_json documentation wrt. casts is misleading Organization: =?UTF-8?B?TsOhcm9kbsOtIHRlY2huaWNrw6Ega25paG92bmE=?= Message-ID: <61bbc030-8eda-5290-0c8c-ca5a1c853888@techlib.cz> Date: Thu, 26 Apr 2018 16:17:20 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit X-Host-Lookup-Failed: Reverse DNS lookup failed for 195.113.241.242 (failed) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Hi, documentation for functions `to_json` and `to_jsonb` states: > Arrays and composites are converted (recursively) to arrays and objects; otherwise, if there is a cast from the type to json, the cast function will be used to perform the conversion; otherwise, a scalar value is produced. For any scalar type other than a number, a Boolean, or a null value, the text representation will be used, in such a fashion that it is a valid json or jsonb value. This might get interpreted in the sense that "if there is a cast from the type to json, the cast function will be used to perform the conversion" regardless of whether the value is an "array or composite". https://stackoverflow.com/questions/35688503/ Would it be possible to adjust the wording in a way that makes this more clear? Or, alternatively, would it be possible to make use of implicit casts in all cases so that the distinction needs not to be made? Best regards Jan Hamal Dvořák