"JSON does not support infinite date values"

Поиск
Список
Период
Сортировка
От Tim Smith
Тема "JSON does not support infinite date values"
Дата
Msg-id CA+HuS5HrCLtFsMPsp+2xt7nv4tBws7JDHhxngYZ73VWJOMyMiA@mail.gmail.com
обсуждение исходный текст
Ответы Re: "JSON does not support infinite date values"  (Andres Freund <andres@2ndquadrant.com>)
Re: "JSON does not support infinite date values"  (Adrian Klaver <adrian.klaver@aklaver.com>)
Список pgsql-general
Hi,

As far as I'm aware, JSON has no data types as such, and so why is
Postgres (9.4.1) attempting to impose its own nonsense constraints ?
Surely it should just insert the word 'infinity' into the JSON output,
just like it displays in a simple SQL query ?

create table app_test.foo(a text,b date,c date,d boolean);

create view app_test.bar as select * from app_test.foo where
b<=now()::date and c>=now()::date and d=true;

insert into app_test.foo(a,b,c,d) values ('zzz','2014-12-31','2014-02-01',true);
insert into app_test.foo(a,b,c,d) values ('zzz','2015-02-01','infinity',true);


foobar=> select * from app_test.bar where a='zzz' order by c asc limit 1;
  a  |     b      |    c     | d
-----+------------+----------+---
 zzz | 2015-02-01 | infinity | t
(1 row)


CREATE FUNCTION app_test.foobar(p_a text) RETURNS json AS $$
DECLARE
v_row app_test.bar%ROWTYPE;
v_json json;
BEGIN
select * into strict v_row from app_test.bar where a=p_a order by c asc limit 1;
select row_to_json(v_row) into v_json;
return v_json;
END;
$$ LANGUAGE plpgsql;


foobar=> select app_test.foobar('zzz');
ERROR:  date out of range
DETAIL:  JSON does not support infinite date values.
CONTEXT:  SQL statement "select row_to_json(v_row)"
PL/pgSQL function app_test.foobar(text) line 7 at SQL statement


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

Предыдущее
От: Torsten Förtsch
Дата:
Сообщение: Locking question
Следующее
От: Andres Freund
Дата:
Сообщение: Re: "JSON does not support infinite date values"