Re: jsonb_set() strictness considered harmful to data

From: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
To: Andrew Dunstan <andrew(dot)dunstan(at)2ndquadrant(dot)com>
Cc: Floris Van Nee <florisvannee(at)optiver(dot)com>, Ariadne Conill <ariadne(at)dereferenced(dot)org>, Tomas Vondra <tomas(dot)vondra(at)2ndquadrant(dot)com>, Mark Felder <feld(at)freebsd(dot)org>, "pgsql-generallists(dot)postgresql(dot)org" <pgsql-general(at)lists(dot)postgresql(dot)org>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: jsonb_set() strictness considered harmful to data
Date: 2019-10-20 17:14:50
Message-ID: CAKFQuwbkKPYhT0S6481L7temmiN+VNrMkExsUjp6FjJnCynd5A@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-hackers

On Sun, Oct 20, 2019 at 5:31 AM Andrew Dunstan <
andrew(dot)dunstan(at)2ndquadrant(dot)com> wrote:

> And yet another is to
> raise an exception, which is easy to write but really punts the issue
> back to the application programmer who will have to decide how to ensure
> they never pass in a NULL parameter.

That's kinda the point - if they never pass NULL they won't encounter any
problems but as soon as the data and their application don't see eye-to-eye
the application developer has to decide what they want to do about it. We
are in no position to decide for them and making it obvious they have a
decision to make and implement here doesn't seem like a improper position
to take.

> Possibly we could even add an extra
> parameter to specify what should be done.
>

Has appeal.

> Should we return NULL in those cases as we do now?
>

Probably the same thing - though I'd accept having the input json being
null result in the output json being null as well.

David J.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Jeff Janes 2019-10-20 18:22:29 Re: Too many SET TimeZone and Application_name queries
Previous Message Tom Lane 2019-10-20 14:10:45 Re: UTC-6 or UTC+6?

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2019-10-20 17:23:10 Re: configure fails for perl check on CentOS8
Previous Message Tels 2019-10-20 16:02:02 Re: Declaring a strict function returns not null / eval speed