On Monday, November 30, 2026, Bruno Wolff III <[email protected]> wrote:

> On Mon, Nov 30, 2026 at 21:04:09 -0800,
>  Adrian Klaver <[email protected]> wrote:
>
>> On 11/30/26 6:07 PM, Bruno Wolff III wrote:
>>
>>>  I expected the final result to be text. The part that surprised me is
>>> the function converting the intermediate steps to text and json, instead of
>>> keeping everything jsonb until the last step.
>>>
>>
You haven’t demonstrated this, you misunderstand what you are seeing.


>
> CREATE UNIQUE INDEX ON cert_orders (
>>>  (order_data->'GetOrderReport'->>'orderNumber'));
>>>
>>
 Neither getorderreport nor ordernumber have a declared type here.


>    "cert_orders_expr_idx" UNIQUE, btree (((order_data ->
>>> 'GetOrderReport'::text) ->> 'orderNumber'::text))
>>>
>>
> Why convert order_data->'GetOrderReport' to text in order to use json ->>
> instead of jsonb ->> in order to get the orderNumber?
>

So when they get parsed they are treated as text, and the explicit
representation is added to the expression.

Order_data->cast(‘getorderreport’ as text)->>cast(’ordernumber’ as text) ;
is an equivalent way to write what you are seeing.

David J.

Reply via email to