Re: BUG #16022: to_json on arrays with unusual lower bound is not intuitive

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: BUG #16022: to_json on arrays with unusual lower bound is not intuitive
Дата
Msg-id 23022.1569422056@sss.pgh.pa.us
обсуждение исходный текст
Ответ на BUG #16022: to_json on arrays with unusual lower bound is not intuitive  (PG Bug reporting form <noreply@postgresql.org>)
Список pgsql-bugs
PG Bug reporting form <noreply@postgresql.org> writes:
> I would expect the array indices of a JSON array to match with the
> subscripts of a postgres array when converting them back and forth.
> However, Postgres lets the JSON array begin at the `lower_bound` of the
> array, not at subscript 1 (= index 0).
> For example, `to_json('[-2:5]={-2,-1,0,1,2,3,4,5}'::int[])` results in
> `[-2,-1,0,1,2,3,4,5]` where I would have expected `[1,2,3,4,5]` (or an
> error, since JSON arrays must not have negative indices).

I can see no reason whatever for either of those definitions to be
better than the established one.  If you want some other conversion
rule, write your own function that behaves the way you want.

            regards, tom lane



В списке pgsql-bugs по дате отправления:

Предыдущее
От: PG Bug reporting form
Дата:
Сообщение: BUG #16022: to_json on arrays with unusual lower bound is not intuitive
Следующее
От: Peter Eisentraut
Дата:
Сообщение: Re: BUG #16020: ICU Collations querys