diff options
author | Andrew Dunstan <andrew@dunslane.net> | 2015-07-24 09:40:46 -0400 |
---|---|---|
committer | Andrew Dunstan <andrew@dunslane.net> | 2015-07-24 09:40:46 -0400 |
commit | d9a356ff2e6bb7ed5fb1145af49fa3e51e68a98a (patch) | |
tree | 2320f3f55faa3d0e3c92f2b4a39d9f22dcaeda46 /src/test/regress/sql/json.sql | |
parent | c1ca3a19df376bcbb6d651d15b9a4ffcaa377ff1 (diff) | |
download | postgresql-d9a356ff2e6bb7ed5fb1145af49fa3e51e68a98a.tar.gz postgresql-d9a356ff2e6bb7ed5fb1145af49fa3e51e68a98a.zip |
Fix treatment of nulls in jsonb_agg and jsonb_object_agg
The wrong is_null flag was being passed to datum_to_json. Also, null
object key values are not permitted, and this was not being checked
for. Add regression tests covering these cases, and also add those tests
to the json set, even though it was doing the right thing.
Fixes bug #13514, initially diagnosed by Tom Lane.
Diffstat (limited to 'src/test/regress/sql/json.sql')
-rw-r--r-- | src/test/regress/sql/json.sql | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/src/test/regress/sql/json.sql b/src/test/regress/sql/json.sql index 8c3b73f5b3e..f631480f967 100644 --- a/src/test/regress/sql/json.sql +++ b/src/test/regress/sql/json.sql @@ -126,7 +126,12 @@ SELECT json_agg(q) FROM generate_series(1,2) x, generate_series(4,5) y) q; -SELECT json_agg(q) +SELECT json_agg(q ORDER BY x, y) + FROM rows q; + +UPDATE rows SET x = NULL WHERE x = 1; + +SELECT json_agg(q ORDER BY x NULLS FIRST, y) FROM rows q; -- non-numeric output @@ -442,7 +447,6 @@ SELECT json_build_object( 'd', json_build_object('e',array[9,8,7]::int[], 'f', (select row_to_json(r) from ( select relkind, oid::regclass as name from pg_class where relname = 'pg_class') r))); - -- empty objects/arrays SELECT json_build_array(); @@ -468,6 +472,11 @@ INSERT INTO foo VALUES (847003,'sub-alpha','GESS90'); SELECT json_build_object('turbines',json_object_agg(serial_num,json_build_object('name',name,'type',type))) FROM foo; +SELECT json_object_agg(name, type) FROM foo; + +INSERT INTO foo VALUES (999999, NULL, 'bar'); +SELECT json_object_agg(name, type) FROM foo; + -- json_object -- one dimension |