Re: Document that jsonpath == can be used as ANY - Mailing list pgsql-hackers

From David G. Johnston
Subject Re: Document that jsonpath == can be used as ANY
Date
Msg-id CAKFQuwb9emZ48OQSgZYbBt7qagrjoyqe1XLhNhNr_Jk89Bjteg@mail.gmail.com
Whole thread
In response to Re: Document that jsonpath == can be used as ANY  (Marcos Pegoraro <marcos@f10.com.br>)
Responses Re: Document that jsonpath == can be used as ANY
List pgsql-hackers
On Wed, Sep 30, 2026 at 11:48 AM Marcos Pegoraro <marcos@f10.com.br> wrote:
Em seg., 17 de ago. de 2026 às 09:04, Marcos Pegoraro <marcos@f10.com.br> escreveu:
Additional example of == operator being used like ANY

I insist on this, there is no documentation on how to find an array of values in a JSON object.

select jsonb_path_query_array('[5,6,7,8,9]', '$[*] ? (@ == $arr)','{"arr": [2,5,8]}') 
-------
[5, 8]


I feel like simply including an example here is insufficient.  There isn't anything special about == going on here; you can substitute >= and get a valid result.  I don't mind the example but this entire behavior of value == value when the lefthand value is scalar and the righthand value is an array (maybe object?) appears undefined.  The sentence there - "(this, and the other comparison operators, work on all JSON scalar values)" - in fact implies that the array version shouldn't work.

David J.

pgsql-hackers by date:

Previous
From: Alexander Lakhin
Date:
Subject: Re: [PATCH] intXshr, intXshl: return error on shift count out of range
Next
From: Tom Lane
Date:
Subject: Re: [PATCH] intXshr, intXshl: return error on shift count out of range