Re: jsonb array-style subscripting

From: Andrew Dunstan <andrew(at)dunslane(dot)net>
To: Kaare Rasmussen <kaare(at)jasonic(dot)dk>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: jsonb array-style subscripting
Date: 2015-08-18 13:52:10
Message-ID: 55D3388A.70006@dunslane.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 08/18/2015 01:11 AM, Kaare Rasmussen wrote:
> On 2015-08-17 22:33, Josh Berkus wrote:
>> So, both perl and python do not allow "deep nesting" of assignments.
>> For example:
>>>>> d = { "a" : { } }
>>>>> d["a"]["a1"]["a2"] = 42
>> Traceback (most recent call last):
>> File "<stdin>", line 1, in <module>
>> KeyError: 'a1'
>
> Not sure I understand what you mean. In Perl you'd do
>
> $ perl -e '%d = (a => {}); $d{a}{a1}{a2} = 42; print $d{a}{a1}{a2}'
> 42
>
> which looks pretty much like what's proposed.
>
>

Indeed, I mentioned recently that perl auto-vivifies intermediate paths
like this.

But we don't do that in jsonb_set, as was discussed back in May, and as
JS doesn't either I think that decision is sound.

cheers

andrew

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Kouhei Kaigai 2015-08-18 14:02:44 Bug? ExecChooseHashTableSize() got assertion failed with crazy number of rows
Previous Message Tom Lane 2015-08-18 13:50:52 Re: allowing wal_level change at run time