From: | Wells Oliver <wells(dot)oliver(at)gmail(dot)com> |
---|---|
To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>, pgsql-admin <pgsql-admin(at)postgresql(dot)org> |
Subject: | Re: json_build_object, numeric types, and function limits on 100 arguments |
Date: | 2021-01-27 06:39:35 |
Message-ID: | CAOC+FBVkTvWHumTdrOC0XBiYZ73NPV760u7+fQ+O2iD7ik6OwA@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-admin |
Thanks, Tom. Doing something like:
with t as ( select somekey, someotherkey from mytable ) select
json_agg(t)->0 from t;
Feels a lot more, errr, natural. Would rather have the object than an array
of 1 containing the object, thus the ->0 but this works well and feels
SQL-ish indeed.
On Tue, Jan 26, 2021 at 1:42 PM Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> Wells Oliver <wells(dot)oliver(at)gmail(dot)com> writes:
> > Yeah, thanks, I thought about that: concatenating a few different objects
> > to make a bigger object. Seemed silly, but if there's not a cleaner
> > solution, it does work.
>
> A more SQL-ish way to deal with this might be to use jsonb_agg()
> or jsonb_object_agg().
>
> regards, tom lane
>
--
Wells Oliver
wells(dot)oliver(at)gmail(dot)com <wellsoliver(at)gmail(dot)com>
From | Date | Subject | |
---|---|---|---|
Next Message | Thomas Kellerer | 2021-01-27 07:04:32 | Re: json_build_object, numeric types, and function limits on 100 arguments |
Previous Message | Tom Lane | 2021-01-26 21:42:19 | Re: json_build_object, numeric types, and function limits on 100 arguments |