Re: minor doc issue in 9.16.2.1.1. Boolean Predicate Check Expressions

From: jian he <jian(dot)universality(at)gmail(dot)com>
To: Bruce Momjian <bruce(at)momjian(dot)us>
Cc: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: minor doc issue in 9.16.2.1.1. Boolean Predicate Check Expressions
Date: 2024-10-17 14:37:46
Message-ID: CACJufxFLT=pTsGhXXQo3WHGzWLZxGu1y=-6b5zoukgew1mdCSw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Thu, Oct 17, 2024 at 9:59 PM Bruce Momjian <bruce(at)momjian(dot)us> wrote:
>
>
> > > > >> the predicate: true, false, or unknown."
> > > > >> "unknown" is wrong, because `select 'unknown'::jsonb;` will fail.
> > > > >> here "unknown" should be "null"? see jsonb_path_query doc entry also.
> > > > >>
> >
> > doc (https://www.postgresql.org/docs/devel/functions-json.html#FUNCTIONS-SQLJSON-CHECK-EXPRESSIONS)
> > <<QUOTE>>
> > While SQL-standard path expressions return the relevant element(s) of
> > the queried JSON value, predicate check expressions return the single
> > three-valued result of the predicate: true, false, or unknown.
> > <<END OF QUOTE>>
> >
> > https://www.postgresql.org/docs/current/datatype-boolean.html
> > says
> > "The boolean type can have several states: “true”, “false”, and a
> > third state, “unknown”, which is represented by the SQL null value."
> >
> > but here
> > select jsonb_path_query('1', '$ == "a"');
> > return JSON null value, not SQL null value.
> >
> > however.
> > select jsonb_path_match('1', '$ == "a"');
> > return SQL null value.
> >
> >
> > maybe we can change to
> > "predicate check expressions return the single three-valued result of
> > the predicate: true, false, or null"
>
> Yes, done in the attached patch.
>

- <literal>false</literal>, or <literal>unknown</literal>.
+ <literal>false</literal>, or <literal>NULL</literal>.

nearby are all examples related to jsonb_path_query.
As mentioned before, jsonb_path_query returns JSON null.
so change to
+ <literal>false</literal>, or <literal>null</literal>
would be better.

since we can select 'null'::jsonb;
but cannot
select 'NULL'::jsonb;

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Bruce Momjian 2024-10-17 16:31:22 Re: minor doc issue in 9.16.2.1.1. Boolean Predicate Check Expressions
Previous Message Peter Eisentraut 2024-10-17 14:10:33 Re: doc: virtual envs with Pl/Python