pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Thomas Kellerer <spam_eater@gmx.net>
To: Марк <kolypto@gmail.com>
To: pgsql-bugs@lists.postgresql.org
Subject: Re: Unexpected behavior of jsonb_set() with a `null` value
Date: Thu, 12 Sep 2019 16:11:52 +0200
Message-ID: <db9745f5-0d85-ed97-9911-9644957be2fc@gmx.net> (raw)
In-Reply-To: <CAOA+1AxbrhVm0HBTDcB97Gmtwp2Nc_qUv2tTbKESusoAQVBexw@mail.gmail.com>
References: <CAOA+1AxbrhVm0HBTDcB97Gmtwp2Nc_qUv2tTbKESusoAQVBexw@mail.gmail.com>

Марк schrieb am 12.09.2019 um 12:55:
> With `jsonb_set()`, when `new_value` is `NULL`, the function would **erase the whole object**:
> 
> postgres=# SELECT jsonb_set('{"something":1}'::jsonb, '{language}', null, true);         
> jsonb_set  
> -----------
>  
> (1 row)
> 
> This is really dangerous for it may lead to data loss. Imaging the `new_value` argument being a function which returns `NULL` values in some cases.
> The expected behavior is, perhaps, to convert an SQL `NULL` value to JSONB null value: 'null'::jsonb
> This way no data would be lost.
> 
> Or at the very least, this behavior should be documented.

I have asked the same: https://www.postgresql.org/message-id/flat/qfkua9%242q0e%241%40blaine.gmane.org

In short: not a bug ;) 






view thread (3+ messages)  latest in thread

Message-ID: <db9745f5-0d85-ed97-9911-9644957be2fc@gmx.net>
Permalink:  ../db9745f5-0d85-ed97-9911-9644957be2fc@gmx.net/
Also on:    postgresql.org/message-id/db9745f5-0d85-ed97-9911-9644957be2fc@gmx.net

 · 

reply

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: spam_eater@gmx.net, kolypto@gmail.com
  Subject: Re: Unexpected behavior of jsonb_set() with a `null` value
  In-Reply-To: <db9745f5-0d85-ed97-9911-9644957be2fc@gmx.net>
  References: <CAOA+1AxbrhVm0HBTDcB97Gmtwp2Nc_qUv2tTbKESusoAQVBexw@mail.gmail.com> <db9745f5-0d85-ed97-9911-9644957be2fc@gmx.net>

* 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