agora inbox for [email protected]  
help / color / mirror / Atom feed
From: Chapman Flack <[email protected]>
To: David E. Wheeler <[email protected]>
To: PostgreSQL Hackers <[email protected]>
Subject: Re: jsonpath: Missing Binary Execution Path?
Date: Thu, 13 Jun 2024 21:09:54 -0400
Message-ID: <[email protected]> (raw)
In-Reply-To: <[email protected]>
References: <[email protected]>

On 06/13/24 16:43, David E. Wheeler wrote:
> Paging Mr. Eisentraut!

I'm not Mr. Eisentraut, but I have at last talked my way into some
access to the standard, so ...

Note 487 emphasizes that JSON path predicates "are not expressions;
instead they form a separate language that can only be invoked within
a <JSON filter expression>".

The only operators usable in a general expression (that is, a
<JSON path wff> are binary + - and binary * / % and unary + -
over a <JSON accessor expression>.

Inside a filter, you get to use a <JSON path predicate>. That's where
you can use ! and && and ||. But ! can only be applied to a
<JSON delimited predicate>: either a <JSON exists path predicate>,
or any other <JSON path predicate> wrapped in parentheses.

On 06/13/24 11:32, David E. Wheeler wrote:
> david=# select jsonb_path_query('true', '$ && $');
> david=# select jsonb_path_query('true', '$.boolean() && $.boolean()');

Those don't work because, as you recognized, they're not inside filters.

> david=# select jsonb_path_query('[1, 3, 7]', '$[*] ? (@.boolean() && @.boolean())');

That doesn't work because the operands of && or || must have the grammatical
form of predicates; it's not enough that they be expressions of boolean
type. '$[*] ? (@.boolean() == true && @.boolean() == true)' ought to work
(though in any other context you'd probably call it a code smell!) because
each operand is now a <JSON comparison predicate>.

Regards,
-Chap





view thread (14+ messages)  latest in thread

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: [email protected]
  Cc: [email protected], [email protected], [email protected]
  Subject: Re: jsonpath: Missing Binary Execution Path?
  In-Reply-To: <[email protected]>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox