From: | Oleksandr Shulgin <oleksandr(dot)shulgin(at)zalando(dot)de> |
---|---|
To: | Dmitry Dolgov <9erthalion6(at)gmail(dot)com> |
Cc: | Arthur Zakirov <a(dot)zakirov(at)postgrespro(dot)ru>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Robert Haas <robertmhaas(at)gmail(dot)com>, Andres Freund <andres(at)anarazel(dot)de>, Michael Paquier <michael(dot)paquier(at)gmail(dot)com>, Oleg Bartunov <obartunov(at)gmail(dot)com>, Peter Eisentraut <peter(dot)eisentraut(at)2ndquadrant(dot)com>, David Steele <david(at)pgmasters(dot)net>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: [HACKERS] [PATCH] Generic type subscripting |
Date: | 2018-03-20 10:09:49 |
Message-ID: | CACACo5Sioo62z8RdXHvRqJtFZf8=D+EzwEXDueXnOpgnNbU3uw@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On Tue, Mar 6, 2018 at 6:21 PM, Dmitry Dolgov <9erthalion6(at)gmail(dot)com> wrote:
>
> One more small update after fd1a421fe6 in attachments.
>
Before looking at the code I have a few comments about documentation:
in json.sgml:
+-- Extract value by key
+SELECT ('{"a": 1}'::jsonb)['a'];
What is the result of running this query? What is the resulting data type?
+-- Extract nested value by key path
+SELECT ('{"a": {"b": {"c": 1}}}'::jsonb)['a']['b']['c'];
+
+-- Extract element by index
+SELECT ('[1, "2", null]'::jsonb)['1'];
What is the result here? Why subscript is a string and not a number? Are
subscription indexes 0- or 1-based?
+-- Update value by key
+UPDATE table_name set jsonb_field['key'] = 1;
+
+-- Select records using where clause with subscripting
+SELECT * from table_name where jsonb_field['key'] = '"value"';
Please capitalize: SET, FROM, WHERE.
Use of double quotes around "value" requires some explanation, I think.
Should the user expect that a suitable index is used by the query planner
for this query?
In other words, I would like to see this part of documentation to be
extended beyond just showcasing the syntax.
Regards,
--
Oleksandr "Alex" Shulgin | Database Engineer | Zalando SE | Tel: +49 176
127-59-707
From | Date | Subject | |
---|---|---|---|
Next Message | Andrew Gierth | 2018-03-20 10:13:53 | Re: BUG #15122: can't import data if table has a constraint with a function calling another function |
Previous Message | Andrew Gierth | 2018-03-20 10:02:27 | Re: PostgreSQL 10: Segmentation fault when using GROUPING SETS with all unsortable columns |