Re: jsonb_set array append hack?

From: Thom Brown <thom(at)linux(dot)com>
To: Andrew Dunstan <andrew(at)dunslane(dot)net>
Cc: Dmitry Dolgov <9erthalion6(at)gmail(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: jsonb_set array append hack?
Date: 2015-09-21 22:11:54
Message-ID: CAA-aLv5n=K_8y+-cSwLgxrQpjVdGUfgpyoM5MgpxN5eqyAeMZg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 21 September 2015 at 22:21, Andrew Dunstan <andrew(at)dunslane(dot)net> wrote:

>
>
> On 09/21/2015 12:13 PM, Dmitry Dolgov wrote:
>
>> > I would expect some kind of error. We're trying to address a position
>> in an array, and we're instead passing a key. If it completes
>> successfully, the chances are it isn't what the user intended.
>>
>> Thanks for the explanation. So, basically, it should be like this, am I
>> right?
>>
>> postgres=# SELECT jsonb_set(
>> '{"name": "Joe", "vehicle_types": ["car", "van"]}'::jsonb,
>> '{vehicle_types, nonsense}',
>> '"motorcycle"', true);
>> ERROR: path element at the position 2 is not an integer
>>
>
>
> That seems reasonable. For that matter, we should probably disallow NULL
> path elements also, shouldn't we?
>

I'd say yes. If someone really wants to name a field "null", they'll just
have to quote it in the path. (e.g. '{contact,"null"}')

--
Thom

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Thomas Munro 2015-09-21 22:25:51 Re: Obsolete use of volatile in walsender.c, walreceiver.c, walreceiverfuncs.c?
Previous Message Josh Berkus 2015-09-21 21:53:40 Re: Streaming Replication clusters and load balancing