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 1iM6l9-0003vG-V6 for pgsql-hackers@arkaria.postgresql.org; Sun, 20 Oct 2019 08:40:20 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1iM6l7-0000qY-RR for pgsql-hackers@arkaria.postgresql.org; Sun, 20 Oct 2019 08:40:17 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iM6l7-0000na-HT; Sun, 20 Oct 2019 08:40:17 +0000 Received: from smtp03.optiver.com ([195.246.114.70]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iM6l1-0006d9-DV; Sun, 20 Oct 2019 08:40:17 +0000 Received: from pps.filterd (smtp03.optiver.com [127.0.0.1]) by smtp03.optiver.com (8.16.0.27/8.16.0.27) with SMTP id x9K8dxHc006726; Sun, 20 Oct 2019 10:39:59 +0200 Received: from opammb0561.comp.optiver.com (opammb0561.comp.optiver.com [10.131.160.1]) by smtp03.optiver.com with ESMTP id 2vqr3589je-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Sun, 20 Oct 2019 10:39:59 +0200 Received: from opammb0561.comp.optiver.com (10.131.160.1) by opammb0561.comp.optiver.com (10.131.160.1) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Sun, 20 Oct 2019 10:39:59 +0200 Received: from opammb0561.comp.optiver.com ([fe80::9d46:f4ee:846a:2858]) by opammb0561.comp.optiver.com ([fe80::9d46:f4ee:846a:2858%17]) with mapi id 15.00.1473.003; Sun, 20 Oct 2019 10:39:59 +0200 From: Floris Van Nee To: Ariadne Conill , Tomas Vondra CC: Andrew Dunstan , "David G. Johnston" , Mark Felder , "pgsql-generallists.postgresql.org" , PostgreSQL Hackers Thread-Topic: jsonb_set() strictness considered harmful to data [External] Thread-Index: AQHVhdrIR8D91Q4zV0mzdRH2L7f3IqdgokaAgAFTvgCAAA6JgIAAA+0AgAAEH4CAACyhgIAABiyAgAD4DF8= Date: Sun, 20 Oct 2019 08:39:58 +0000 Message-ID: <1571560798575.47024@Optiver.com> References: <7dc242bd-b78f-2e0d-0c38-7b4b299f11bf@2ndQuadrant.com> <20191019161851.v7dwloiiav5yrpwu@development> <20191019192723.luarxhq57qkzuncw@development>, In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-transport-fromentityheader: Hosted x-originating-ip: [10.131.160.182] x-tm-as-product-ver: SMEX-14.0.0.1158-8.5.1020-24988.003 x-tm-as-result: No-10-0.281700-8.000000 x-tmase-matchedrid: LFhZ4D3Qpay4hTqNTG14SWg4D2QV/2zL6r3HCixfuKcc4ri4RJV/1bzY +0P/SfZ749H65z6f1B9geWyP1iSzwCwwtxRkxyN3ydRP56yRRA8eIblhH0Sn6Up12IXZajx5bgY 8Qwl4o874E6OjbJfiKHSSMu78YvtPyWmcpiBNo7ucxB01DrjF96LwP+jjbL9KUHcBn70iJQfuCf aiqSyg+JoE0IDrW+hIUNDjd2RbdrnfX2sZfyOJoaubsOtSWY2QfyYDewMOrQBxaUCQQDd7gx9kw 80dd4buY0MubbMDzlxjXM3KOWZkKw4rIEDtGkKwHFuzqhD5YBpg5vOLB3Y1WN/SJznOClIxoCAK AoIb2WYM/vKzx1GusR3L41iYoouZju59deBWleg= x-tm-as-user-approved-sender: Yes x-tm-as-user-blocked-sender: No x-tmase-result: 10-0.281700-8.000000 x-tmase-version: SMEX-14.0.0.1158-8.5.1020-24988.003 x-tm-snts-smtp: 810CF02F68B78D57801140556CFE61CC8454FA327EB33CBD3CD8BDD53CFADAB72000:8 Content-Type: multipart/alternative; boundary="_000_157156079857547024Optivercom_" MIME-Version: 1.0 Subject: jsonb_set() strictness considered harmful to data X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2019-10-20_03:,, signatures=0 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --_000_157156079857547024Optivercom_ Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable FWIW I've been bitten by this 'feature' more than once as well, accidentall= y erasing a column. Now I usually write js =3D jsonb_set(js, coalesce(new_c= olumn, 'null'::jsonb)) to prevent erasing the whole column, and instead set= ting the value to a jsonb null value, but I also found the STRICT behavior = very surprising at first.. -Floris --_000_157156079857547024Optivercom_ Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable

FWIW I've been bitten by this 'feature' more than once as well, accident= ally erasing a column. Now I usually write js =3D jsonb_set(js, c= oalesce(new_column, 'null'::jsonb)) to prevent erasing the whole column, an= d instead setting the value to a jsonb null value, but I also found the STRICT behavior very surprising at first..


-Floris


--_000_157156079857547024Optivercom_--