Re: SQL/JSON: functions - Mailing list pgsql-hackers

From Andrew Dunstan
Subject Re: SQL/JSON: functions
Date
Msg-id 2c692328-02aa-413d-de32-1e2df76b89af@dunslane.net
Whole thread Raw
In response to Re: SQL/JSON: functions  (Himanshu Upadhyaya <upadhyaya.himanshu@gmail.com>)
List pgsql-hackers
On 12/9/21 09:04, Himanshu Upadhyaya wrote:
>
>
>
> 2)
> I am not sure if below is required as per SQL standard, ORACLE is
> allowing to construct JSON_OBJECT bases on the records in the table as
> below, but postgres parser is not allowing:
> create table test (id varchar(10), value int);
> insert into test values ('a',1);
> insert into test values ('b',2);
> insert into test values ('c',3);
> select json_object(*) from test; --postgres does not support
> postgres=# select json_object(*) from test;
> ERROR:  syntax error at or near "*"
> LINE 1: select json_object(*) from test;
>
>

You can spell that a bit differently today, e.g.

    select to_json(r) from test r;

I don't know either if it's in the spec, but building in support for *
in this context seems likely to be fairly complex and have very little
added utility.


cheers


andrew

--
Andrew Dunstan
EDB: https://www.enterprisedb.com




pgsql-hackers by date:

Previous
From: Melanie Plageman
Date:
Subject: Re: pg_stat_bgwriter.buffers_backend is pretty meaningless (and more?)
Next
From: Andrew Dunstan
Date:
Subject: Re: pg_upgrade should truncate/remove its logs before running