Re: Why is JSONB field automatically cast as TEXT?

From: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
To: Ben Uphoff <buphoff(at)villagemd(dot)com>
Cc: "pgsql-general(at)lists(dot)postgresql(dot)org" <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: Re: Why is JSONB field automatically cast as TEXT?
Date: 2018-09-17 18:11:42
Message-ID: CAKFQuwYRCjohY4j8VwzML2tTPZVanJ0yw_MFnpSKW55NS66RZA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Monday, September 17, 2018, Ben Uphoff <buphoff(at)villagemd(dot)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.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Seamus Abshere 2018-09-17 19:34:31 Too many BitmapAnds in the wild
Previous Message Ben Uphoff 2018-09-17 18:03:47 Why is JSONB field automatically cast as TEXT?