Re: [GENERAL] How to stop array_to_json from interpolating column names that weren't there

2017-07-20 Thread Tom Lane
"David G. Johnston" writes: > On Wed, Jul 19, 2017 at 8:53 PM, Guyren Howe wrote: >> Thanks. Seeking greater understanding, why is json_agg(*) not equivalent? > ​Are you referring to the fact that ​this provokes an error? > "select json_agg(*) from schemata;" The reason for that is that we inte

Re: [GENERAL] How to stop array_to_json from interpolating column names that weren't there

2017-07-19 Thread David G. Johnston
On Wed, Jul 19, 2017 at 8:53 PM, Guyren Howe wrote: > Thanks. Seeking greater understanding, why is json_agg(*) not equivalent? > ​Are you referring to the fact that ​this provokes an error? "select json_agg(*) from schemata;" The json_agg(expression) function has an arity of 1 (i.e., one inpu

Re: [GENERAL] How to stop array_to_json from interpolating column names that weren't there

2017-07-19 Thread Guyren Howe
On Jul 19, 2017, at 20:47 , Paul Jungwirth wrote: > >> which is great. I have an array of perfect JSON objects. Now I just need >> to turn that into a single JSON object. > > I think you're saying you want it as a single JSON *array*, right? An object > of objects doesn't make sense. Assuming

Re: [GENERAL] How to stop array_to_json from interpolating column names that weren't there

2017-07-19 Thread Paul Jungwirth
which is great. I have an array of perfect JSON objects. Now I just need to turn that into a single JSON object. I think you're saying you want it as a single JSON *array*, right? An object of objects doesn't make sense. Assuming that's right, this seems to work: db1=# select json_agg(schema

Re: [GENERAL] How to stop array_to_json from interpolating column names that weren't there

2017-07-19 Thread Tom Lane
Guyren Howe writes: > I have an array of perfect JSON objects. Now I just need to turn that into a > single JSON object. But when I do the obvious: > SELECT array_to_json( > SELECT > ARRAY_AGG(foo) AS foos > FROM ( > SELECT

[GENERAL] How to stop array_to_json from interpolating column names that weren't there

2017-07-19 Thread Guyren Howe
9.6 I’ve a view that shows information about schemas: SELECT schemata.catalog_name, schemata.schema_name, ('/'::text || (schemata.schema_name)::text) AS schema_name_address FROM information_schema.schemata ORDER BY schemata.catalog_name, schemata.schema_name Fine. I now want to tur