From: | Neil Conway <neil(dot)conway(at)gmail(dot)com> |
---|---|
To: | pgsql-bugs(at)postgresql(dot)org |
Subject: | row_to_json(), NULL values, and AS |
Date: | 2018-06-14 22:57:27 |
Message-ID: | CAOW5sYa3Wp7KozCuzjOdw6PiOYPi6D=VvRybtH2S=2C0SVmRmA@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-bugs pgsql-hackers |
Hi,
The following behavior does not seem self-consistent to me:
postgres=# select json_agg(row_to_json(x)) from (select *, null from
generate_series(1, 3)) x;
json_agg
-----------------------------------------------------------------------------------------------------------------------
[{"generate_series":1,"?column?":null},
{"generate_series":2,"?column?":null},
{"generate_series":3,"?column?":null}]
(1 row)
postgres=# select json_agg(row_to_json(x)) from (select *,
row_to_json(null) as jjj from generate_series(1, 3)) x;
json_agg
--------------------------------------------------------------------------------------------------------
[{"generate_series":1,"jjj":null}, {"generate_series":2,"jjj":null},
{"generate_series":3,"jjj":null}]
(1 row)
postgres=# select json_agg(row_to_json(x)) from (select *,
row_to_json(null) from generate_series(1, 3)) x;
json_agg
--------------------
[null, null, null]
(1 row)
In particular, it is unclear to me why removing the targetlist alias
in the subquery in the third example should change the result set of
the parent query.
Thanks,
Neil
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2018-06-14 23:28:24 | Re: row_to_json(), NULL values, and AS |
Previous Message | Robert Haas | 2018-06-14 21:26:33 | Re: BUG #15237: I got "ERROR: source for a multiple-column UPDATE item must be a sub-SELECT or ROW() expression" |
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2018-06-14 23:07:06 | Bogus dependency calculation for expressions involving casts |
Previous Message | R, Siva | 2018-06-14 22:55:19 | Re: Duplicate Item Pointers in Gin index |