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 FB75F45B-7D0D-4CD1-AD7F-1AF6A1AD0311@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:

> It will take a predicate, but seems to always return true:
>
> regression=# select '{"a":[1,2,3,4,5]}'::jsonb @? '$.a[*] < 5' ;
> ?column?
> ----------
> t
> (1 row)
>
> regression=# select '{"a":[1,2,3,4,5]}'::jsonb @? '$.a[*] > 5' ;
> ?column?
> ----------
> t
> (1 row)

Just for the sake of clarity, this return value is “correct,” because @? and other functions and operators that expect
SQLstandard statements evaluate the SET returned by the JSONPath statement, but predicate check expressions don’t
returna set, but a always a single scalar value (true, false, or null). From the POV of the code expecting SQL standard
JSONPathresults, that’s a set of one. @? sees that the set is not empty so returns true. 

Best,

David




pgsql-hackers by date:

Previous
From: Jeff Davis
Date:
Subject: Re: [17] CREATE COLLATION default provider
Next
From: Tom Lane
Date:
Subject: Re: Patch: Improve Boolean Predicate JSON Path Docs