Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1i8PsR-0003hc-PG for pgsql-bugs@arkaria.postgresql.org; Thu, 12 Sep 2019 14:15:15 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1i8PsQ-0007KU-CQ for pgsql-bugs@arkaria.postgresql.org; Thu, 12 Sep 2019 14:15:14 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1i8PpN-00058A-UN for pgsql-bugs@lists.postgresql.org; Thu, 12 Sep 2019 14:12:06 +0000 Received: from mout.kundenserver.de ([212.227.17.24]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.92) (envelope-from ) id 1i8PpG-0005TV-QC for pgsql-bugs@lists.postgresql.org; Thu, 12 Sep 2019 14:12:04 +0000 Received: from [10.8.0.75] ([185.40.248.10]) by mrelayeu.kundenserver.de (mreue108 [212.227.15.145]) with ESMTPSA (Nemesis) id 1MmD6U-1iYzCU0ToG-00iDTH; Thu, 12 Sep 2019 16:11:54 +0200 Subject: Re: Unexpected behavior of jsonb_set() with a `null` value To: =?UTF-8?B?0JzQsNGA0Lo=?= , pgsql-bugs@lists.postgresql.org References: From: Thomas Kellerer Message-ID: Date: Thu, 12 Sep 2019 16:11:52 +0200 User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.23) Gecko/20090812 Thunderbird/2.0.0.23 Mnenhy/0.7.6.666 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: de-DE Content-Transfer-Encoding: 8bit X-Provags-ID: V03:K1:thZaBRq7UUA/rEp4pdMOrbiRVva4PfT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TFRM2ddtT1joTSHaur/MPs8Rii7pKrUG+BUYI1MgzFlel/zyGTgpZvXFMh7uS1PE crrxIB7gOlYjSVZ/48Ca0zEt7NQV960RE9kjNYlDg= List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Марк 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 ;)