| From: | Dmitry Dolgov <9erthalion6(at)gmail(dot)com> |
|---|---|
| To: | Thom Brown <thom(at)linux(dot)com> |
| Cc: | Andrew Dunstan <andrew(at)dunslane(dot)net>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org> |
| Subject: | Re: jsonb_set array append hack? |
| Date: | 2015-09-21 16:13:05 |
| Message-ID: | CA+q6zcV=z_daXD8U-Kgt9hU9Xo=4Le3pKmKT6T6O9OBBvj_CVw@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
> 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
On 20 September 2015 at 23:50, Thom Brown <thom(at)linux(dot)com> wrote:
> On 20 September 2015 at 16:17, Dmitry Dolgov <9erthalion6(at)gmail(dot)com>
> wrote:
>
>> I'm sorry, but I'm not sure, what behavior is expected in this case?
>> Right now the following logic was implemented:
>> "we trying to set an element inside an array, but we've got a
>> non-integer path item
>> ("nonsense" in this particular case), so we're going to add a new
>> element at the end of array by default"
>>
>> If it's wrong, should we refuse to perform such kind of operations, or
>> should we replace
>> "vehicle_type": ["car", "van"]
>> to
>> "vehicle_type: {"nonsense": "motorcycle"}
>> ?
>>
>
> (please bottom-post)
>
> 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.
>
> Thom
>
| Attachment | Content-Type | Size |
|---|---|---|
| non_integer_in_path.patch | application/octet-stream | 2.3 KB |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Tom Lane | 2015-09-21 16:14:21 | Re: Bug in numeric multiplication |
| Previous Message | Dean Rasheed | 2015-09-21 15:21:10 | Re: Bug in numeric multiplication |