jsonb_set() strictness considered harmful to data

From: Floris Van Nee <florisvannee(at)Optiver(dot)com>
To: Ariadne Conill <ariadne(at)dereferenced(dot)org>, Tomas Vondra <tomas(dot)vondra(at)2ndquadrant(dot)com>
Cc: Andrew Dunstan <andrew(dot)dunstan(at)2ndquadrant(dot)com>, "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>, Mark Felder <feld(at)freebsd(dot)org>, "pgsql-generallists(dot)postgresql(dot)org" <pgsql-general(at)lists(dot)postgresql(dot)org>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: jsonb_set() strictness considered harmful to data
Date: 2019-10-20 08:39:58
Message-ID: 1571560798575.47024@Optiver.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-hackers

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

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Steve Atkins 2019-10-20 09:13:04 Re: jsonb_set() strictness considered harmful to data
Previous Message Adrian Klaver 2019-10-20 00:21:17 Re: releasing space

Browse pgsql-hackers by date

  From Date Subject
Next Message Steve Atkins 2019-10-20 09:13:04 Re: jsonb_set() strictness considered harmful to data
Previous Message Peter Eisentraut 2019-10-20 08:26:40 Re: Clean up MinGW def file generation