From: Christophe Pettus <xof@thebuild.com>
To: Radics Geza <radicsge@gmail.com>
Cc: Tomas Vondra <tomas.vondra@2ndquadrant.com>
Cc: pgsql-bugs@lists.postgresql.org
Subject: Re: JSON array is not updated if updating with empty array
Date: Fri, 6 Mar 2020 11:24:16 -0800
Message-ID: <79492C80-5C4C-4D29-8EEE-CD0F66469034@thebuild.com> (raw)
In-Reply-To: <CAJFbfO_vv_Zdsd9hQ5qNpVD6m2a20d0jdVgqA=XSdG_evcpH0A@mail.gmail.com>
References: <CAJFbfO84H34Fqyxgk2S8erN+FarooDeKS+vMM1dvvs9gPkq5oA@mail.gmail.com>
<20200306191814.5fioiqy6ahxv6i7n@development>
<CAJFbfO_vv_Zdsd9hQ5qNpVD6m2a20d0jdVgqA=XSdG_evcpH0A@mail.gmail.com>
> On Mar 6, 2020, at 11:21, Radics Geza <radicsge@gmail.com> wrote:
>
> I should have written that the precondition is that the column should contains a non-empty json array before the update as in the example.
> (The insert works, the update also works if the previous content was not an array before e.g. null or '{}' but not as above)
I'm still not able to reproduce it on 11.7:
xof=# create table t (j jsonb);
CREATE TABLE
xof=# insert into t values('[{"b": 1}]');
INSERT 0 1
xof=# update t set j = '[{"a": 1}]';
UPDATE 1
xof=# table t;
j
------------
[{"a": 1}]
(1 row)
xof=# update t set j = '[]';
UPDATE 1
xof=# table t;
j
----
[]
(1 row)
--
-- Christophe Pettus
xof@thebuild.com
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-bugs@postgresql.org
Cc: xof@thebuild.com, radicsge@gmail.com, tomas.vondra@2ndquadrant.com
Subject: Re: JSON array is not updated if updating with empty array
In-Reply-To: <79492C80-5C4C-4D29-8EEE-CD0F66469034@thebuild.com>
References: <CAJFbfO84H34Fqyxgk2S8erN+FarooDeKS+vMM1dvvs9gPkq5oA@mail.gmail.com> <20200306191814.5fioiqy6ahxv6i7n@development> <CAJFbfO_vv_Zdsd9hQ5qNpVD6m2a20d0jdVgqA=XSdG_evcpH0A@mail.gmail.com> <79492C80-5C4C-4D29-8EEE-CD0F66469034@thebuild.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox