A little confusion about JSON Path - Mailing list pgsql-general

From Thomas Kellerer
Subject A little confusion about JSON Path
Date
Msg-id 8dcb9b9d-4863-b7e9-c3dc-e4ab2d01e918@gmx.net
Whole thread Raw
Responses Re: A little confusion about JSON Path
List pgsql-general
Hello,

I don't understand why the following two JSON Path expressions aren't doing the same thing in Postgres 12:

    with sample (data) as (
      values
        ('{"k1": {"list":[1,2,3]}}'::jsonb)
    )
    select data, 
           jsonb_path_exists(data, '$.k1.list.type() ? (@ == "array")'), -- returns true as expected
           jsonb_path_exists(data, '$.k1.list ? (@.type() == "array")') -- returns false - not expected
    from sample;


Apparently "@.type()" returns something different then "$.k1.list.type()"

But maybe I simply don't understand how the @ is supposed to work.

Regards
Thomas



pgsql-general by date:

Previous
From: "Daniel Verite"
Date:
Subject: Re: Text search lexer's handling of hyphens and negatives
Next
From: Imre Samu
Date:
Subject: Re: Regarding db dump with Fc taking very long time to completion