Re: json ->> operator precedence - Mailing list pgsql-general

From John McKown
Subject Re: json ->> operator precedence
Date
Msg-id CAAJSdjj=G8qCDuotojGbfBDjfjSEBZrBsp5n-ND-hEm9TBNdJQ@mail.gmail.com
Whole thread Raw
In response to Re: json ->> operator precedence  (John McKown <john.archie.mckown@gmail.com>)
List pgsql-general


On Wed, Aug 5, 2015 at 8:35 AM, John McKown <john.archie.mckown@gmail.com> wrote:
​​

​Looks correct to me. As I understand it the ::jsonb is NOT an operator! It is a syntactic construct for a CAST(). An equivalent which might make more sense is:

select CASE WHEN CAST('{"a":null}' AS JSONB)->>'a' IS NULL THEN 'yes' ELSE 'no' END;​​

Oh, an CAST() may look like a function call, but it is also a syntactic element. I.e. there is not a function called "CAST". 


​Well, I messed that up a bit. CAST is not a "syntactic element" as I was thinking. But it's not really a function call either but is closer to a function call than an operator in nature (I my ignorant opinion) . I was thinking it was a "compile time" operation, but it, like a function call, is a run-time operation. I think that using the CASE() makes it plainer that it is _not_ an operation like ->> or - and makes the precedence issue plainer.

 
--

Schrodinger's backup: The condition of any backup is unknown until a restore is attempted.

Yoda of Borg, we are. Futile, resistance is, yes. Assimilated, you will be.

He's about as useful as a wax frying pan.

10 to the 12th power microphones = 1 Megaphone

Maranatha! <><
John McKown

pgsql-general by date:

Previous
From: Geoff Winkless
Date:
Subject: Re: json ->> operator precedence
Next
From: Tom Lane
Date:
Subject: Re: idle processes