Re: jsonb_set() strictness considered harmful to data

From: Andrew Dunstan <andrew(dot)dunstan(at)2ndquadrant(dot)com>
To: Tomas Vondra <tomas(dot)vondra(at)2ndquadrant(dot)com>
Cc: Mark Felder <feld(at)FreeBSD(dot)org>, pgsql-general(at)lists(dot)postgresql(dot)org, pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: jsonb_set() strictness considered harmful to data
Date: 2019-10-19 16:32:10
Message-ID: 11b0453d-65d0-c9dc-ce8d-a33665f672c1@2ndQuadrant.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-hackers


On 10/19/19 12:18 PM, Tomas Vondra wrote:
> On Sat, Oct 19, 2019 at 11:26:50AM -0400, Andrew Dunstan wrote:
>
> Not sure, but that seems rather confusing to me, because it's mixing SQL
> NULL and JSON null, i.e. it's not clear to me why
>
>    jsonb_set(..., "...", NULL)
>
> should do the same thing as
>
>    jsonb_set(..., "...", 'null':jsonb)
>
> I'm not entirely surprised it's what MySQL does ;-) but I'd say treating
> it as a deletion of the key (just like MSSQL) is somewhat more sensible.
> But I admit it's quite subjective.
>

That's yet another variant, which just reinforces my view that there is
no guaranteed-intuitive behaviour here.

OTOH, to me, turning jsonb_set into jsonb_delete for some case seems ...
odd.

cheers

andrew

--
Andrew Dunstan https://www.2ndQuadrant.com
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services

In response to

Browse pgsql-general by date

  From Date Subject
Next Message David G. Johnston 2019-10-19 16:32:54 Re: jsonb_set() strictness considered harmful to data
Previous Message Tomas Vondra 2019-10-19 16:31:15 Re: jsonb_set() strictness considered harmful to data

Browse pgsql-hackers by date

  From Date Subject
Next Message David G. Johnston 2019-10-19 16:32:54 Re: jsonb_set() strictness considered harmful to data
Previous Message Tomas Vondra 2019-10-19 16:31:15 Re: jsonb_set() strictness considered harmful to data