Re: Why is JSONB field automatically cast as TEXT? - Mailing list pgsql-general

From David G. Johnston
Subject Re: Why is JSONB field automatically cast as TEXT?
Date
Msg-id CAKFQuwYRCjohY4j8VwzML2tTPZVanJ0yw_MFnpSKW55NS66RZA@mail.gmail.com
Whole thread Raw
In response to Why is JSONB field automatically cast as TEXT?  (Ben Uphoff <buphoff@villagemd.com>)
List pgsql-general
On Monday, September 17, 2018, Ben Uphoff <buphoff@villagemd.com> wrote:

SELECT (((mytable.ajsonbcolumn -> ‘somedata’::text) -> ‘nested’::text) ->> ‘first_name’::text) AS fname FROM mytable

It’s casting the untyped literal constants (somedata, neated, first_name) to text because everything must be typed.  It is not casting the first or intermediate jsonb results to text.  The final output is text because of the ->> operator.

:: binds more tightly than the other operators.

Jsonb->('somedata'::text)

David J.

pgsql-general by date:

Previous
From: Ben Uphoff
Date:
Subject: Why is JSONB field automatically cast as TEXT?
Next
From: Seamus Abshere
Date:
Subject: Too many BitmapAnds in the wild