Re: SQL:2023 JSON simplified accessor support

From: Andrew Dunstan <andrew(at)dunslane(dot)net>
To: Alexandra Wang <alexandra(dot)wang(dot)oss(at)gmail(dot)com>, Peter Eisentraut <peter(at)eisentraut(dot)org>
Cc: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: SQL:2023 JSON simplified accessor support
Date: 2024-09-26 17:16:38
Message-ID: 9be7b272-aca6-485b-bec7-386997c7970c@dunslane.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers


On 2024-09-26 Th 11:45 AM, Alexandra Wang wrote:
> Hi,
>
> I didn’t run pgindent earlier, so here’s the updated version with the
> correct indentation. Hope this helps!

This is a really nice feature, and provides a lot of expressive power
for such a small piece of code.

I notice this doesn't seem to work for domains over json and jsonb.

andrew(at)~=# create domain json_d as json;
CREATE DOMAIN
andrew(at)~=# create table test_json_dot(id int, test_json json_d);
CREATE TABLE
andrew(at)~=# insert into test_json_dot select 1, '{"a": 1, "b": 42}'::json;
INSERT 0 1      |          |
andrew(at)~=# select (test_json_dot.test_json).b, json_query(test_json,
'lax $.b' WITH CONDITIONAL WRAPPER NULL ON EMPTY NULL ON ERROR) as
expected from test_json_dot;
ERROR:  column notation .b applied to type json_d, which is not a
composite type
LINE 1: select (test_json_dot.test_json).b, json_query(test_json, 'l...

I'm not sure that's a terribly important use case, but we should
probably make it work. If it's a domain we should get the basetype of
the domain. There's some example code in src/backend/utils/adt/jsonfuncs.c

cheers

andrew

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

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Shayon Mukherjee 2024-09-26 17:39:23 Re: Proposal to Enable/Disable Index using ALTER INDEX
Previous Message Alvaro Herrera 2024-09-26 16:53:01 Re: not null constraints, again