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

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Guyren Howe <guyren(at)gmail(dot)com>
Cc: pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: How to stop array_to_json from interpolating column names that weren't there
Date: 2017-07-20 03:01:55
Message-ID: 13756.1500519715@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Guyren Howe <guyren(at)gmail(dot)com> 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
> row_to_json(schemata_)
> FROM
> schemata_)
> AS
> foo
> )

> I get a syntax error.

Well, yeah, you're missing parentheses around the scalar sub-select.
(Whether fixing that will give the behavior you want is unclear,
but the syntax error is clear.)

regards, tom lane

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Igor Korot 2017-07-20 03:13:10 Re:
Previous Message Glen Huang 2017-07-20 02:55:50 Re: Is it possible to define a constraint based on the values in other rows in the current table?