diff options
Diffstat (limited to 'src/test/regress/sql/json.sql')
-rw-r--r-- | src/test/regress/sql/json.sql | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/src/test/regress/sql/json.sql b/src/test/regress/sql/json.sql index 440398b9b9f..61273555aae 100644 --- a/src/test/regress/sql/json.sql +++ b/src/test/regress/sql/json.sql @@ -54,3 +54,46 @@ SELECT 'truf'::json; -- ERROR, not a keyword SELECT 'trues'::json; -- ERROR, not a keyword SELECT ''::json; -- ERROR, no value SELECT ' '::json; -- ERROR, no value + +--constructors +-- array_to_json + +SELECT array_to_json(array(select 1 as a)); +SELECT array_to_json(array_agg(q),false) from (select x as b, x * 2 as c from generate_series(1,3) x) q; +SELECT array_to_json(array_agg(q),true) from (select x as b, x * 2 as c from generate_series(1,3) x) q; +SELECT array_to_json(array_agg(q),false) + FROM ( SELECT $$a$$ || x AS b, y AS c, + ARRAY[ROW(x.*,ARRAY[1,2,3]), + ROW(y.*,ARRAY[4,5,6])] AS z + FROM generate_series(1,2) x, + generate_series(4,5) y) q; +SELECT array_to_json(array_agg(x),false) from generate_series(5,10) x; +SELECT array_to_json('{{1,5},{99,100}}'::int[]); + +-- row_to_json +SELECT row_to_json(row(1,'foo')); + +SELECT row_to_json(q) +FROM (SELECT $$a$$ || x AS b, + y AS c, + ARRAY[ROW(x.*,ARRAY[1,2,3]), + ROW(y.*,ARRAY[4,5,6])] AS z + FROM generate_series(1,2) x, + generate_series(4,5) y) q; + +SELECT row_to_json(q,true) +FROM (SELECT $$a$$ || x AS b, + y AS c, + ARRAY[ROW(x.*,ARRAY[1,2,3]), + ROW(y.*,ARRAY[4,5,6])] AS z + FROM generate_series(1,2) x, + generate_series(4,5) y) q; + +CREATE TEMP TABLE rows AS +SELECT x, 'txt' || x as y +FROM generate_series(1,3) AS x; + +SELECT row_to_json(q,true) +FROM rows q; + +SELECT row_to_json(row((select array_agg(x) as d from generate_series(5,10) x)),false); |