Patch: Improve Boolean Predicate JSON Path Docs

From: "David E(dot) Wheeler" <david(at)justatheory(dot)com>
To: pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Patch: Improve Boolean Predicate JSON Path Docs
Date: 2023-10-14 20:40:05
Message-ID: 7262A188-59CA-4A8A-AAD7-83D4FF0B9758@justatheory.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hackers,

Following up from a suggestion from Tom Lane[1] to improve the documentation of boolean predicate JSON path expressions, please find enclosed a draft patch to do so. It does three things:

1. Converts all of the example path queries to use jsonb_path_query() and show the results, to make it clearer what the behaviors are.

2. Replaces the list of deviations from the standards with a new subsection, with each deviation in its own sub-subsection. The regex section is unchanged, but I’ve greatly expanded the boolean expression JSON path section with examples comparing standard filter expressions and nonstandard boolean predicates. I’ve also added an exhortation not use boolean expressions with @? or standard path expressions with @@.

3. While converting the modes section to use jsonb_path_query() and show the results, I also added an example of strict mode returning an error.

Follow-ups I’d like to make:

1. Expand the modes section to show how the types of results can vary depending on the mode, thanks to the flattening. Examples:

david=# select jsonb_path_query('{"a":[1,2,3,4,5]}', '$.a ?(@[*] > 2)');
jsonb_path_query
------------------
3
4
5
(3 rows)

david=# select jsonb_path_query('{"a":[1,2,3,4,5]}', 'strict $.a ?(@[*] > 2)');
jsonb_path_query
------------------
[1, 2, 3, 4, 5]

2. Improve the descriptions and examples for @?/jsonb_path_exists() and @@/jsonb_path_match().

Best,

David

[1] https://www.postgresql.org/message-id/1229727.1680535592%40sss.pgh.pa.us

Attachment Content-Type Size
jsonpath-pred-docs.patch application/octet-stream 10.2 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message David E. Wheeler 2023-10-14 20:45:35 Re: Patch: Improve Boolean Predicate JSON Path Docs
Previous Message David Steele 2023-10-14 19:45:33 Re: Requiring recovery.signal or standby.signal when recovering with a backup_label