Re: Unexpected zero results - Mailing list pgsql-general

From Thomas Kellerer
Subject Re: Unexpected zero results
Date
Msg-id 0910192d-ed0f-e455-c591-c4d59b6172f2@gmx.net
Whole thread Raw
In response to Unexpected zero results  (Viliam Ďurina <viliam.durina@gmail.com>)
List pgsql-general
Viliam Ďurina schrieb am 23.03.2022 um 17:56:
> Hello all,
>
> I'm experimenting with JSON-path functions, and stumbled upon this query:
>
>    SELECT jsonb_path_query('[1,2,3]', '$[*]?(@ == 4)')
>
> It returns 0 rows. I expected it to return one row with `null` value.
> Isn't it the case that `SELECT <some expression>` should always
> return 1 row?

jsonb_path_query is a set returning function, so it's actually more like this:

     SELECT *
     FROM jsonb_path_query('[1,2,3]', '$[*]?(@ == 4)')

Then it's obvious why no row is returned.

That's one of the reasons I never use set-returning functions in the SELECT list.




pgsql-general by date:

Previous
From: Viliam Ďurina
Date:
Subject: Unexpected zero results
Next
From: Viliam Ďurina
Date:
Subject: Re: Unexpected zero results