Re: JSON path query returns duplicate values

From: Thomas Kellerer <shammat(at)gmx(dot)net>
To: pgsql-sql(at)lists(dot)postgresql(dot)org
Subject: Re: JSON path query returns duplicate values
Date: 2020-12-29 14:14:05
Message-ID: 9c68a03b-f9f1-a21f-3ee7-a0c1162e6b08@gmx.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Thomas Kellerer schrieb am 21.12.2020 um 10:43:
> I wonder why this query
>
>   select jsonb_path_query_array(col, '$.**.itemName')
>   from (
>     values ('{"items": [{"itemName": "a", "items": [{"itemName": "b"}]}]}'::jsonb)
>   ) as t(col)
>
> returns each itemName twice: ["a", "a", "b", "b"]
>
> I would have expected: ["a", "b"]

Is this a bug or intended?

If it's intended, I would really like to know the reason.
At least to me the result is quite surprsing.

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Sachin Kumar 2021-01-07 10:15:02 how to make query
Previous Message Thomas Kellerer 2020-12-21 09:43:18 JSON path query returns duplicate values