Search Postgresql Archives

"JSON does not support infinite date values"

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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


-- 
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux