1. Andrew Dunstan
  2. pgdevel

Commits

Andrew Dunstan  committed dd47491

fix json results

  • Participants
  • Parent commits bbe25a0
  • Branches rowexprs

Comments (0)

Files changed (1)

File src/test/regress/expected/json.out

View file
  • Ignore whitespace
 (1 row)
 
 SELECT array_to_json(array_agg(q),false) from (select x as b, x * 2 as c from generate_series(1,3) x) q;
-                   array_to_json                   
----------------------------------------------------
- [{"f1":1,"f2":2},{"f1":2,"f2":4},{"f1":3,"f2":6}]
+                array_to_json                
+---------------------------------------------
+ [{"b":1,"c":2},{"b":2,"c":4},{"b":3,"c":6}]
 (1 row)
 
 SELECT array_to_json(array_agg(q),true) from (select x as b, x * 2 as c from generate_series(1,3) x) q;
-   array_to_json   
--------------------
- [{"f1":1,"f2":2},+
-  {"f1":2,"f2":4},+
-  {"f1":3,"f2":6}]
+  array_to_json  
+-----------------
+ [{"b":1,"c":2},+
+  {"b":2,"c":4},+
+  {"b":3,"c":6}]
 (1 row)
 
 SELECT array_to_json(array_agg(q),false)
                ROW(y.*,ARRAY[4,5,6])] AS z 
          FROM generate_series(1,2) x, 
               generate_series(4,5) y) q;
-                                                                                                                                       array_to_json                                                                                                                                       
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
- [{"f1":"a1","f2":4,"f3":[{"f1":1,"f2":[1,2,3]},{"f1":4,"f2":[4,5,6]}]},{"f1":"a1","f2":5,"f3":[{"f1":1,"f2":[1,2,3]},{"f1":5,"f2":[4,5,6]}]},{"f1":"a2","f2":4,"f3":[{"f1":2,"f2":[1,2,3]},{"f1":4,"f2":[4,5,6]}]},{"f1":"a2","f2":5,"f3":[{"f1":2,"f2":[1,2,3]},{"f1":5,"f2":[4,5,6]}]}]
+                                                                                                                                 array_to_json                                                                                                                                 
+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+ [{"b":"a1","c":4,"z":[{"f1":1,"f2":[1,2,3]},{"f1":4,"f2":[4,5,6]}]},{"b":"a1","c":5,"z":[{"f1":1,"f2":[1,2,3]},{"f1":5,"f2":[4,5,6]}]},{"b":"a2","c":4,"z":[{"f1":2,"f2":[1,2,3]},{"f1":4,"f2":[4,5,6]}]},{"b":"a2","c":5,"z":[{"f1":2,"f2":[1,2,3]},{"f1":5,"f2":[4,5,6]}]}]
 (1 row)
 
 SELECT array_to_json(array_agg(x),false) from generate_series(5,10) x;
                ROW(y.*,ARRAY[4,5,6])] AS z 
       FROM generate_series(1,2) x, 
            generate_series(4,5) y) q;
-                              row_to_json                              
------------------------------------------------------------------------
- {"f1":"a1","f2":4,"f3":[{"f1":1,"f2":[1,2,3]},{"f1":4,"f2":[4,5,6]}]}
- {"f1":"a1","f2":5,"f3":[{"f1":1,"f2":[1,2,3]},{"f1":5,"f2":[4,5,6]}]}
- {"f1":"a2","f2":4,"f3":[{"f1":2,"f2":[1,2,3]},{"f1":4,"f2":[4,5,6]}]}
- {"f1":"a2","f2":5,"f3":[{"f1":2,"f2":[1,2,3]},{"f1":5,"f2":[4,5,6]}]}
+                            row_to_json                             
+--------------------------------------------------------------------
+ {"b":"a1","c":4,"z":[{"f1":1,"f2":[1,2,3]},{"f1":4,"f2":[4,5,6]}]}
+ {"b":"a1","c":5,"z":[{"f1":1,"f2":[1,2,3]},{"f1":5,"f2":[4,5,6]}]}
+ {"b":"a2","c":4,"z":[{"f1":2,"f2":[1,2,3]},{"f1":4,"f2":[4,5,6]}]}
+ {"b":"a2","c":5,"z":[{"f1":2,"f2":[1,2,3]},{"f1":5,"f2":[4,5,6]}]}
 (4 rows)
 
 SELECT row_to_json(q,true) 
                ROW(y.*,ARRAY[4,5,6])] AS z 
       FROM generate_series(1,2) x, 
            generate_series(4,5) y) q;
-                     row_to_json                      
-------------------------------------------------------
- {"f1":"a1",                                         +
-  "f2":4,                                            +
-  "f3":[{"f1":1,"f2":[1,2,3]},{"f1":4,"f2":[4,5,6]}]}
- {"f1":"a1",                                         +
-  "f2":5,                                            +
-  "f3":[{"f1":1,"f2":[1,2,3]},{"f1":5,"f2":[4,5,6]}]}
- {"f1":"a2",                                         +
-  "f2":4,                                            +
-  "f3":[{"f1":2,"f2":[1,2,3]},{"f1":4,"f2":[4,5,6]}]}
- {"f1":"a2",                                         +
-  "f2":5,                                            +
-  "f3":[{"f1":2,"f2":[1,2,3]},{"f1":5,"f2":[4,5,6]}]}
+                     row_to_json                     
+-----------------------------------------------------
+ {"b":"a1",                                         +
+  "c":4,                                            +
+  "z":[{"f1":1,"f2":[1,2,3]},{"f1":4,"f2":[4,5,6]}]}
+ {"b":"a1",                                         +
+  "c":5,                                            +
+  "z":[{"f1":1,"f2":[1,2,3]},{"f1":5,"f2":[4,5,6]}]}
+ {"b":"a2",                                         +
+  "c":4,                                            +
+  "z":[{"f1":2,"f2":[1,2,3]},{"f1":4,"f2":[4,5,6]}]}
+ {"b":"a2",                                         +
+  "c":5,                                            +
+  "z":[{"f1":2,"f2":[1,2,3]},{"f1":5,"f2":[4,5,6]}]}
 (4 rows)
 
 CREATE TEMP TABLE rows AS