From: raf <raf@raf.org>
To: pgsql-generallists.postgresql.org <pgsql-general@lists.postgresql.org>
To: PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Subject: Re: jsonb_set() strictness considered harmful to data
Date: Tue, 22 Oct 2019 09:16:05 +1100
Message-ID: <20191021221605.qrdthyxzmjxwm3r3@raf.org> (raw)
In-Reply-To: <CAKmB1PEuvXeXLNiQjRCStRKYoMEB7U9+S3bupXvHuoURiGEa6A@mail.gmail.com>
References: <a2c965cc-7d90-ed89-d50f-b2c046d4499e@2ndQuadrant.com>
<20191019192723.luarxhq57qkzuncw@development>
<CAAOiGNxmXSUdOzBg+7vWMzTjDELmiZi_dqGz355tKy+OgbCZpA@mail.gmail.com>
<1571560798575.47024@Optiver.com>
<34a7ff88-0d86-0990-4eac-48159df8d7f2@2ndQuadrant.com>
<CAKFQuwbkKPYhT0S6481L7temmiN+VNrMkExsUjp6FjJnCynd5A@mail.gmail.com>
<5db07acf-bc75-edf8-60af-905c0adadb68@2ndQuadrant.com>
<CAKmB1PEUO4nJMODBEob4ySHYSRX1EE8TUixYf=Dg-tFHfNnt1g@mail.gmail.com>
<20191020233115.jjy6lqd4vsyrdbbo@raf.org>
<CAKmB1PEuvXeXLNiQjRCStRKYoMEB7U9+S3bupXvHuoURiGEa6A@mail.gmail.com>
Steven Pousty wrote:
> On Sun, Oct 20, 2019 at 4:31 PM raf <raf@raf.org> wrote:
>
> > Steven Pousty wrote:
> >
> > > I would think though that raising an exception is better than a
> > > default behavior which deletes data.
> >
> > I can't help but feel the need to make the point that
> > the function is not deleting anything. It is just
> > returning null. The deletion of data is being performed
> > by an update statement that uses the function's return
> > value to set a column value.
> >
> > I don't agree that raising an exception in the function
> > is a good idea (perhaps unless it's valid to assume
> > that this function will only ever be used in such a
> > context). Making the column not null (as already
> > suggested) and having the update statement itself raise
> > the exception seems more appropriate if an exception is
> > desirable. But that presumes an accurate understanding
> > of the behaviour of jsonb_set.
> >
> > Really, I think the best fix would be in the
> > documentation so that everyone who finds the function
> > in the documentation understands its behaviour
> > immediately.
> >
> Hey Raf
>
> In a perfect world I would agree with you. But often users do not read ALL
> the documentation before they use the function in their code OR they are
> not sure that the condition applies to them (until it does).
I'm well aware of that, hence the statement that this
information needs to appear at the place in the
documentation where the user is first going to
encounter the function (i.e. in the table where its
examples are). Even putting it in a note box further
down the page might not be enough (but hopefully it
will be).
cheers,
raf
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-general@postgresql.org
Cc: raf@raf.org, pgsql-hackers@lists.postgresql.org
Subject: Re: jsonb_set() strictness considered harmful to data
In-Reply-To: <20191021221605.qrdthyxzmjxwm3r3@raf.org>
References: <a2c965cc-7d90-ed89-d50f-b2c046d4499e@2ndQuadrant.com> <20191019192723.luarxhq57qkzuncw@development> <CAAOiGNxmXSUdOzBg+7vWMzTjDELmiZi_dqGz355tKy+OgbCZpA@mail.gmail.com> <1571560798575.47024@Optiver.com> <34a7ff88-0d86-0990-4eac-48159df8d7f2@2ndQuadrant.com> <CAKFQuwbkKPYhT0S6481L7temmiN+VNrMkExsUjp6FjJnCynd5A@mail.gmail.com> <5db07acf-bc75-edf8-60af-905c0adadb68@2ndQuadrant.com> <CAKmB1PEUO4nJMODBEob4ySHYSRX1EE8TUixYf=Dg-tFHfNnt1g@mail.gmail.com> <20191020233115.jjy6lqd4vsyrdbbo@raf.org> <CAKmB1PEuvXeXLNiQjRCStRKYoMEB7U9+S3bupXvHuoURiGEa6A@mail.gmail.com> <20191021221605.qrdthyxzmjxwm3r3@raf.org>
* 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