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

From David E. Wheeler
Subject Re: Patch: Improve Boolean Predicate JSON Path Docs
Date
Msg-id 8B5A33DB-793C-4FF3-A6F0-89D92AAD312A@justatheory.com
Whole thread Raw
In response to Re: Patch: Improve Boolean Predicate JSON Path Docs  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: Patch: Improve Boolean Predicate JSON Path Docs
List pgsql-hackers
On Jan 20, 2024, at 12:34, Tom Lane <tgl@sss.pgh.pa.us> wrote:

> Surely we're not helping anybody by leaving that behavior in place.
> Making it do something useful, throwing an error, or returning NULL
> all seem superior to this.  I observe that @@ returns NULL for the
> path type it doesn't like, so maybe that's what to do here.

I agree it would be far better for the behavior to be consistent, but frankly would like to see them raise an error.
Ideallythe hit would suggest the proper alternative operator or function to use, and maybe link to the docs that
describethe difference between SQL-standard JSONPath and "predicate check expressions”, and how they have separate
operatorsand functions. 

I think of them as practically different data types (and wish they were, TBH). It makes sense that passing a JSON
containmentexpression[1] would raise an error; so should passing the wrong flavor of JSONPath. 

> BTW, jsonb_path_query_array and jsonb_path_query_first seem to
> take both types of path, like jsonb_path_query, so ISTM they need
> docs changes too.

Happy to update the patch, either to add those docs or, if we change the behavior to return a NULL or raise an error,
thenwith that information, instead. 

Best,

David

  [1]: https://www.postgresql.org/docs/current/datatype-json.html#JSON-CONTAINMENT




pgsql-hackers by date:

Previous
From: Pavel Stehule
Date:
Subject: Re: proposal: psql: show current user in prompt
Next
From: Tom Lane
Date:
Subject: Re: introduce dynamic shared memory registry