to_json documentation wrt. casts is misleading

From: Jan Hamal Dvořák <jan(dot)hamal(dot)dvorak(at)techlib(dot)cz>
To: pgsql-bugs(at)postgresql(dot)org
Subject: to_json documentation wrt. casts is misleading
Date: 2018-04-26 14:17:20
Message-ID: 61bbc030-8eda-5290-0c8c-ca5a1c853888@techlib.cz
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

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

Browse pgsql-bugs by date

  From Date Subject
Next Message Michael Meskes 2018-04-26 16:20:43 Re: BUG #15176: ecpg generation error
Previous Message Gopichand Gatte 2018-04-26 14:01:10 Regarding PostgreSQL