Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sHvS8-00BbHi-OH for pgsql-hackers@arkaria.postgresql.org; Fri, 14 Jun 2024 01:10:04 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1sHvS6-00AniM-JY for pgsql-hackers@arkaria.postgresql.org; Fri, 14 Jun 2024 01:10:03 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sHvS6-00AniE-24 for pgsql-hackers@lists.postgresql.org; Fri, 14 Jun 2024 01:10:03 +0000 Received: from 009.lax.mailroute.net ([199.89.1.12]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sHvS4-001YUU-41 for pgsql-hackers@lists.postgresql.org; Fri, 14 Jun 2024 01:10:02 +0000 Received: from localhost (localhost [127.0.0.1]) by 009.lax.mailroute.net (Postfix) with ESMTP id 4W0h5d44ZqzlgMVW; Fri, 14 Jun 2024 01:09:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=acm.org; h= content-transfer-encoding:content-type:content-type:in-reply-to :mime-version:user-agent:date:date:message-id:from:from :references:subject:subject:received:received; s=mr01; t= 1718327396; x=1720919397; bh=tAsIVpNAZwRROxBNCtQaZnXKdM/8VjEWxTM 7q7K2Dfw=; b=jSbFKtyiNf8Zp409+XpIDYb80zuMBUoyBgovlBaAJfIgj8b9F0q 5hWVuJE4UJUKoOA/Hb+8s0b/g/0UXR43kAIMmeULaEsGPjzwOmZSIk5VmIEmV1W6 PmECglVcndIJNtl0YwRnxd5smQ8QOxoSg6qKedFd8EbF/MTZoAKM7uRNMNiMXFJZ 5KX52ClhNLY29IHvPHc0cjLYMHtuGLubClIJ9oI4KqxI1egrTjAMT+znV40koGpw OIJhzG7NcduzLv0bxcM3vNuMqdxhEsZ/bYtmNLjpaz+qyUNCRDO4iXDH8NwuzUKZ 0knxzmpeQ8cNDbKiPnh7lbxULUJkMqsizSA== X-Virus-Scanned: by MailRoute Received: from 009.lax.mailroute.net ([127.0.0.1]) by localhost (009.lax [127.0.0.1]) (mroute_mailscanner, port 10029) with LMTP id h4VW5VUaDPSL; Fri, 14 Jun 2024 01:09:56 +0000 (UTC) Received: from [73.103.120.3] (c-73-103-120-3.hsd1.in.comcast.net [73.103.120.3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) (Authenticated sender: jcflack@acm.org) by 009.lax.mailroute.net (Postfix) with ESMTPSA id 4W0h5c0VbqzlgMVV; Fri, 14 Jun 2024 01:09:55 +0000 (UTC) Subject: Re: jsonpath: Missing Binary Execution Path? To: "David E. Wheeler" , PostgreSQL Hackers References: <551C85FD-C79C-4FCF-9563-014E74B41F70@justatheory.com> From: Chapman Flack X-Enigmail-Draft-Status: N1110 Message-ID: <666B9862.5000608@acm.org> Date: Thu, 13 Jun 2024 21:09:54 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.7.0 MIME-Version: 1.0 In-Reply-To: <551C85FD-C79C-4FCF-9563-014E74B41F70@justatheory.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk 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 ". The only operators usable in a general expression (that is, a are binary + - and binary * / % and unary + - over a . Inside a filter, you get to use a . That's where you can use ! and && and ||. But ! can only be applied to a : either a , or any other 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 . Regards, -Chap