diff options
| author | Andrew Dunstan | 2015-02-26 17:25:21 +0000 |
|---|---|---|
| committer | Andrew Dunstan | 2015-02-26 17:25:21 +0000 |
| commit | bda76c1c8cfb1d11751ba6be88f0242850481733 (patch) | |
| tree | de3272dade43151c7f9668e18cb8111f2da70bb6 /src/test | |
| parent | fd6a3f3ad4067f1b8fc28e9de6e99e5936d82161 (diff) | |
Render infinite date/timestamps as 'infinity' for json/jsonb
Commit ab14a73a6c raised an error in these cases and later the
behaviour was copied to jsonb. This is what the XML code, which we
then adopted, does, as the XSD types don't accept infinite values.
However, json dates and timestamps are just strings as far as json is
concerned, so there is no reason not to render these values as
'infinity'.
The json portion of this is backpatched to 9.4 where the behaviour was
introduced. The jsonb portion only affects the development branch.
Per gripe on pgsql-general.
Diffstat (limited to 'src/test')
| -rw-r--r-- | src/test/regress/expected/json.out | 24 | ||||
| -rw-r--r-- | src/test/regress/expected/json_1.out | 24 | ||||
| -rw-r--r-- | src/test/regress/expected/jsonb.out | 24 | ||||
| -rw-r--r-- | src/test/regress/expected/jsonb_1.out | 24 | ||||
| -rw-r--r-- | src/test/regress/sql/json.sql | 6 | ||||
| -rw-r--r-- | src/test/regress/sql/jsonb.sql | 6 |
6 files changed, 108 insertions, 0 deletions
diff --git a/src/test/regress/expected/json.out b/src/test/regress/expected/json.out index 16704363dc6..3942c3bee91 100644 --- a/src/test/regress/expected/json.out +++ b/src/test/regress/expected/json.out @@ -426,6 +426,30 @@ select to_json(timestamptz '2014-05-28 12:22:35.614298-04'); (1 row) COMMIT; +select to_json(date '2014-05-28'); + to_json +-------------- + "2014-05-28" +(1 row) + +select to_json(date 'Infinity'); + to_json +------------ + "infinity" +(1 row) + +select to_json(timestamp 'Infinity'); + to_json +------------ + "infinity" +(1 row) + +select to_json(timestamptz 'Infinity'); + to_json +------------ + "infinity" +(1 row) + --json_agg SELECT json_agg(q) FROM ( SELECT $$a$$ || x AS b, y AS c, diff --git a/src/test/regress/expected/json_1.out b/src/test/regress/expected/json_1.out index 807814641dd..38f15262883 100644 --- a/src/test/regress/expected/json_1.out +++ b/src/test/regress/expected/json_1.out @@ -426,6 +426,30 @@ select to_json(timestamptz '2014-05-28 12:22:35.614298-04'); (1 row) COMMIT; +select to_json(date '2014-05-28'); + to_json +-------------- + "2014-05-28" +(1 row) + +select to_json(date 'Infinity'); + to_json +------------ + "infinity" +(1 row) + +select to_json(timestamp 'Infinity'); + to_json +------------ + "infinity" +(1 row) + +select to_json(timestamptz 'Infinity'); + to_json +------------ + "infinity" +(1 row) + --json_agg SELECT json_agg(q) FROM ( SELECT $$a$$ || x AS b, y AS c, diff --git a/src/test/regress/expected/jsonb.out b/src/test/regress/expected/jsonb.out index 6c6ed950f08..0d558901e9d 100644 --- a/src/test/regress/expected/jsonb.out +++ b/src/test/regress/expected/jsonb.out @@ -330,6 +330,30 @@ select to_jsonb(timestamptz '2014-05-28 12:22:35.614298-04'); (1 row) COMMIT; +select to_jsonb(date '2014-05-28'); + to_jsonb +-------------- + "2014-05-28" +(1 row) + +select to_jsonb(date 'Infinity'); + to_jsonb +------------ + "infinity" +(1 row) + +select to_jsonb(timestamp 'Infinity'); + to_jsonb +------------ + "infinity" +(1 row) + +select to_jsonb(timestamptz 'Infinity'); + to_jsonb +------------ + "infinity" +(1 row) + --jsonb_agg CREATE TEMP TABLE rows AS SELECT x, 'txt' || x as y diff --git a/src/test/regress/expected/jsonb_1.out b/src/test/regress/expected/jsonb_1.out index f30148d51c1..694b6ea5f5c 100644 --- a/src/test/regress/expected/jsonb_1.out +++ b/src/test/regress/expected/jsonb_1.out @@ -330,6 +330,30 @@ select to_jsonb(timestamptz '2014-05-28 12:22:35.614298-04'); (1 row) COMMIT; +select to_jsonb(date '2014-05-28'); + to_jsonb +-------------- + "2014-05-28" +(1 row) + +select to_jsonb(date 'Infinity'); + to_jsonb +------------ + "infinity" +(1 row) + +select to_jsonb(timestamp 'Infinity'); + to_jsonb +------------ + "infinity" +(1 row) + +select to_jsonb(timestamptz 'Infinity'); + to_jsonb +------------ + "infinity" +(1 row) + --jsonb_agg CREATE TEMP TABLE rows AS SELECT x, 'txt' || x as y diff --git a/src/test/regress/sql/json.sql b/src/test/regress/sql/json.sql index 53a37a88439..53832a01fa1 100644 --- a/src/test/regress/sql/json.sql +++ b/src/test/regress/sql/json.sql @@ -111,6 +111,12 @@ SET LOCAL TIME ZONE -8; select to_json(timestamptz '2014-05-28 12:22:35.614298-04'); COMMIT; +select to_json(date '2014-05-28'); + +select to_json(date 'Infinity'); +select to_json(timestamp 'Infinity'); +select to_json(timestamptz 'Infinity'); + --json_agg SELECT json_agg(q) diff --git a/src/test/regress/sql/jsonb.sql b/src/test/regress/sql/jsonb.sql index 53cc2393c62..676e1a7d4c9 100644 --- a/src/test/regress/sql/jsonb.sql +++ b/src/test/regress/sql/jsonb.sql @@ -74,6 +74,12 @@ SET LOCAL TIME ZONE -8; select to_jsonb(timestamptz '2014-05-28 12:22:35.614298-04'); COMMIT; +select to_jsonb(date '2014-05-28'); + +select to_jsonb(date 'Infinity'); +select to_jsonb(timestamp 'Infinity'); +select to_jsonb(timestamptz 'Infinity'); + --jsonb_agg CREATE TEMP TABLE rows AS |
