Re: "JSON does not support infinite date values"

Поиск
Список
Период
Сортировка
От Adrian Klaver
Тема Re: "JSON does not support infinite date values"
Дата
Msg-id 54EF7548.4000400@aklaver.com
обсуждение исходный текст
Ответ на Re: "JSON does not support infinite date values"  (Tim Smith <randomdev4+postgres@gmail.com>)
Список pgsql-general
On 02/26/2015 08:27 AM, Tim Smith wrote:
>> Seriously? Json not supporting infinity makes it useless. Ok, so it has
>> been useless for the, I don't know, last 10 years?
>
> Just face it Andres, it should have never been coded that way in the
> first place.  The fact that it appears that nobody in the last 10
> years has used "infinity" in conjunction with JSON functions is your
> problem, not mine.

You really need to pay attention to the conversation instead of getting
wrapped up in your own drama. As was stated and shown, previously(9.3+)
Postgres did what you want. The behavior change you discovered was done
as part of the changes in 9.4 to be ISO 8601 compliant:

http://www.postgresql.org/docs/9.4/interactive/release-9-4.html

When converting values of type date, timestamp or timestamptz to JSON,
render the values in a format compliant with ISO 8601 (Andrew Dunstan)

Previously such values were rendered according to the current DateStyle
setting; but many JSON processors require timestamps to be in ISO 8601
format. If necessary, the previous behavior can be obtained by
explicitly casting the datetime value to text before passing it to the
JSON conversion function


Reading the above gets you:

test=# select version();
                                                            version


-----------------------------------------------------------------------------------------------------------------------------
  PostgreSQL 9.4.1 on i686-pc-linux-gnu, compiled by gcc (SUSE Linux)
4.8.1 20130909 [gcc-4_8-branch revision 202388], 32-bit
(1 row)


test=# select to_json(row('infinity'::date::text));
       to_json
-------------------
  {"f1":"infinity"}
(1 row)


Now both a core developer and the developer driving the JSON bus agree
with you that the above is probably not the best solution and the
behavior should return to its previous state. So please, take yes for an
answer and move on.

>
>


--
Adrian Klaver
adrian.klaver@aklaver.com


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

Предыдущее
От: Hanns Hartman
Дата:
Сообщение: Re: How is autovacuum affected by a change in year.
Следующее
От: Adrian Klaver
Дата:
Сообщение: Re: "JSON does not support infinite date values"