Patch: Improve Boolean Predicate JSON Path Docs - Mailing list pgsql-hackers

From David E. Wheeler
Subject Patch: Improve Boolean Predicate JSON Path Docs
Date
Msg-id 7262A188-59CA-4A8A-AAD7-83D4FF0B9758@justatheory.com
Whole thread Raw
Responses Re: Patch: Improve Boolean Predicate JSON Path Docs
Re: Patch: Improve Boolean Predicate JSON Path Docs
List 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
behaviorsare. 

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
examplescomparing standard filter expressions and nonstandard boolean predicates. I’ve also added an exhortation not
useboolean 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
modereturning 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

pgsql-hackers by date:

Previous
From: David Steele
Date:
Subject: Re: Requiring recovery.signal or standby.signal when recovering with a backup_label
Next
From: "David E. Wheeler"
Date:
Subject: Re: Patch: Improve Boolean Predicate JSON Path Docs