pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Floris Van Nee <florisvannee@Optiver.com>
To: Ariadne Conill <ariadne@dereferenced.org>
To: Tomas Vondra <tomas.vondra@2ndquadrant.com>
Cc: Andrew Dunstan <andrew.dunstan@2ndquadrant.com>
Cc: David G. Johnston <david.g.johnston@gmail.com>
Cc: Mark Felder <feld@freebsd.org>
Cc: pgsql-generallists.postgresql.org <pgsql-general@lists.postgresql.org>
Cc: PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Subject: jsonb_set() strictness considered harmful to data
Date: Sun, 20 Oct 2019 08:39:58 +0000
Message-ID: <1571560798575.47024@Optiver.com> (raw)
In-Reply-To: <CAAOiGNxmXSUdOzBg+7vWMzTjDELmiZi_dqGz355tKy+OgbCZpA@mail.gmail.com>
References: <CAAOiGNwUsgM-UBqsJH_mriCFr-JCPxD+pQoXNvyOEQPc+YHQRQ@mail.gmail.com>
	<d7a4e2b2-e009-4d79-aa5b-82bcf96aad2f@www.fastmail.com>
	<7dc242bd-b78f-2e0d-0c38-7b4b299f11bf@2ndQuadrant.com>
	<20191019161851.v7dwloiiav5yrpwu@development>
	<CAKFQuwa0epfqMsJ=yz8t+ASmdf5PoFXhXj=9DBpoHa2i_67nJw@mail.gmail.com>
	<a2c965cc-7d90-ed89-d50f-b2c046d4499e@2ndQuadrant.com>
	<20191019192723.luarxhq57qkzuncw@development>
	<CAAOiGNxmXSUdOzBg+7vWMzTjDELmiZi_dqGz355tKy+OgbCZpA@mail.gmail.com>

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


-Floris

view thread (83+ messages)  latest in thread

Message-ID: <1571560798575.47024@Optiver.com>
Permalink:  ../1571560798575.47024@Optiver.com/
Also on:    postgresql.org/message-id/1571560798575.47024@Optiver.com

 · 

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-general@postgresql.org
  Cc: florisvannee@Optiver.com, ariadne@dereferenced.org, tomas.vondra@2ndquadrant.com, andrew.dunstan@2ndquadrant.com, david.g.johnston@gmail.com, feld@freebsd.org, pgsql-hackers@lists.postgresql.org
  Subject: Re: jsonb_set() strictness considered harmful to data
  In-Reply-To: <1571560798575.47024@Optiver.com>
  References: <CAAOiGNwUsgM-UBqsJH_mriCFr-JCPxD+pQoXNvyOEQPc+YHQRQ@mail.gmail.com> <d7a4e2b2-e009-4d79-aa5b-82bcf96aad2f@www.fastmail.com> <7dc242bd-b78f-2e0d-0c38-7b4b299f11bf@2ndQuadrant.com> <20191019161851.v7dwloiiav5yrpwu@development> <CAKFQuwa0epfqMsJ=yz8t+ASmdf5PoFXhXj=9DBpoHa2i_67nJw@mail.gmail.com> <a2c965cc-7d90-ed89-d50f-b2c046d4499e@2ndQuadrant.com> <20191019192723.luarxhq57qkzuncw@development> <CAAOiGNxmXSUdOzBg+7vWMzTjDELmiZi_dqGz355tKy+OgbCZpA@mail.gmail.com> <1571560798575.47024@Optiver.com>

* 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