pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Jan Hamal Dvořák <jan.hamal.dvorak@techlib.cz>
To: pgsql-bugs@postgresql.org
Subject: to_json documentation wrt. casts is misleading
Date: Thu, 26 Apr 2018 16:17:20 +0200
Message-ID: <61bbc030-8eda-5290-0c8c-ca5a1c853888@techlib.cz> (raw)

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





Message-ID: <61bbc030-8eda-5290-0c8c-ca5a1c853888@techlib.cz>
Permalink:  ../61bbc030-8eda-5290-0c8c-ca5a1c853888@techlib.cz/
Also on:    postgresql.org/message-id/61bbc030-8eda-5290-0c8c-ca5a1c853888@techlib.cz

 · 

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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: jan.hamal.dvorak@techlib.cz
  Subject: Re: to_json documentation wrt. casts is misleading
  In-Reply-To: <61bbc030-8eda-5290-0c8c-ca5a1c853888@techlib.cz>
  References: <61bbc030-8eda-5290-0c8c-ca5a1c853888@techlib.cz>

* 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