Re: More new SQL/JSON item methods

From: Jeevan Chalke <jeevan(dot)chalke(at)enterprisedb(dot)com>
To: Kyotaro Horiguchi <horikyota(dot)ntt(at)gmail(dot)com>
Cc: tgl(at)sss(dot)pgh(dot)pa(dot)us, andrew(at)dunslane(dot)net, peter(at)eisentraut(dot)org, pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: More new SQL/JSON item methods
Date: 2024-02-02 05:31:31
Message-ID: CAM2+6=VkwQ82oo+7rUY8OQHYDEMveAWVhBjvt8WNbSO8FXbzMw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Thu, Feb 1, 2024 at 11:25 AM Kyotaro Horiguchi <horikyota(dot)ntt(at)gmail(dot)com>
wrote:

> At Thu, 1 Feb 2024 09:22:22 +0530, Jeevan Chalke <
> jeevan(dot)chalke(at)enterprisedb(dot)com> wrote in
> > On Thu, Feb 1, 2024 at 7:24 AM Kyotaro Horiguchi <
> horikyota(dot)ntt(at)gmail(dot)com>
> > wrote:
> >
> > > At Thu, 01 Feb 2024 10:49:57 +0900 (JST), Kyotaro Horiguchi <
> > > horikyota(dot)ntt(at)gmail(dot)com> wrote in
> > > > By the way, while playing with this feature, I noticed the following
> > > > error message:
> > > >
> > > > > select jsonb_path_query('1.1' , '$.boolean()');
> > > > > ERROR: numeric argument of jsonpath item method .boolean() is out
> of
> > > range for type boolean
> > > >
> > > > The error message seems a bit off to me. For example, "argument '1.1'
> > > > is invalid for type [bB]oolean" seems more appropriate for this
> > > > specific issue. (I'm not ceratin about our policy on the spelling of
> > > > Boolean..)
> > >
> > > Or, following our general convention, it would be spelled as:
> > >
> > > 'invalid argument for type Boolean: "1.1"'
> > >
> >
> > jsonpath way:
>
> Hmm. I see.
>
> > ERROR: argument of jsonpath item method .boolean() is invalid for type
> > boolean
> >
> > or, if we add input value, then
> >
> > ERROR: argument "1.1" of jsonpath item method .boolean() is invalid for
> > type boolean
> >
> > And this should work for all the error types, like out of range, not
> valid,
> > invalid input, etc, etc. Also, we don't need separate error messages for
> > string input as well, which currently has the following form:
> >
> > "string argument of jsonpath item method .%s() is not a valid
> > representation.."
>
> Agreed.
>

Attached are patches based on the discussion.

>
> regards.
>
> --
> Kyotaro Horiguchi
> NTT Open Source Software Center
>

--
Jeevan Chalke

*Principal, ManagerProduct Development*

edbpostgres.com

Attachment Content-Type Size
v1-0002-Improve-error-message-for-NaN-or-Infinity-inputs-.patch application/octet-stream 7.1 KB
v1-0001-Merge-error-messages-in-the-same-pattern-in-jsonp.patch application/octet-stream 3.8 KB
v1-0003-Unify-error-messages-for-various-jsonpath-item-me.patch application/octet-stream 21.3 KB
v1-0004-Show-input-value-in-the-error-message-of-various-.patch application/octet-stream 25.4 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message jian he 2024-02-02 05:53:52 Re: SQL:2011 application time
Previous Message Tom Lane 2024-02-02 05:27:55 Re: Commitfest 2024-01 is now closed