On Tue, Mar 6, 2018 at 6:21 PM, Dmitry Dolgov <9erthali...@gmail.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