PostgreSQL Bugs

Collected from the PG bugs email list.

Bug ID16489
PG Version12.1
OSmacOS 10.14
Opened2020-06-11 02:29:49+00
Reported byDahan Jeremy

Body of first available message related to this bug follows.

The following bug has been logged on the website:

Bug reference:      16489
Logged by:          Dahan Jeremy
Email address:      (redacted)
PostgreSQL version: 12.1
Operating system:   macOS 10.14

I found this very strange behavior of the jsonb_path_query function :

Example : 
SELECT jsonb_path_query('{"a":["b","c"]}'::jsonb, '$.a ? (@ == $d)' ,
When using the jsonb_path_query function with a vars argument that includes
an array (here with key d), I cannot compare the queried array against the
vars array.
Instead, I get a per element comparison, which means instead of returning 

the query returns 

just like the query
SELECT jsonb_path_query('{"a":["b","c"]}'::jsonb, '$.a[*] ? (@ == $d)' ,
(notice the $.a[*] instead of the $.a)

Interestingly, this means that the following query also returns the same
SELECT jsonb_path_query('{"a":["b","c"]}'::jsonb, '$.a[*] ? (@ != $d)' ,
(notice the != instead of the ==)

I could not find mentions of this strange behavior in the documentation, and
I would love to know if there is a way of comparing an array against another
array in a jsonb_path_query function call (without using a WHERE clause).
By the way, the current behavior can be useful for finding intersections of

Thank you for this truly incredible project

Best regards,

Jeremy Dahan


2020-06-11 02:29:49+00PG Bug reporting formBUG #16489: Cannot strictly compare arrays in jsonb_path_query call that uses vars