From: | "Peter J(dot) Holzer" <hjp-pgsql(at)hjp(dot)at> |
---|---|
To: | pgsql-general(at)lists(dot)postgresql(dot)org |
Subject: | Re: jsonb_set() strictness considered harmful to data |
Date: | 2019-10-22 23:01:46 |
Message-ID: | 20191022230146.GB12201@hjp.at |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general pgsql-hackers |
On 2019-10-21 09:39:13 -0700, Steven Pousty wrote:
> Turning a JSON null into a SQL null and thereby "deleting" the data
> is not the path of least surprises.
But it doesn't do that: A JSON null is perfectly fine:
wds=> select jsonb_set('{"a": 1, "b": 2}'::jsonb, '{c}', 'null'::jsonb);
╔═════════════════════════════╗
║ jsonb_set ║
╟─────────────────────────────╢
║ {"a": 1, "b": 2, "c": null} ║
╚═════════════════════════════╝
(1 row)
It is trying to replace a part of the JSON object with an SQL NULL (i.e.
unknown) which returns SQL NULL:
wds=> select jsonb_set('{"a": 1, "b": 2}'::jsonb, '{c}', NULL);
╔═══════════╗
║ jsonb_set ║
╟───────────╢
║ (∅) ║
╚═══════════╝
(1 row)
hp
--
_ | Peter J. Holzer | we build much bigger, better disasters now
|_|_) | | because we have much more sophisticated
| | | hjp(at)hjp(dot)at | management tools.
__/ | http://www.hjp.at/ | -- Ross Anderson <https://www.edge.org/>
From | Date | Subject | |
---|---|---|---|
Next Message | Peter J. Holzer | 2019-10-22 23:11:24 | Re: jsonb_set() strictness considered harmful to data |
Previous Message | Peter J. Holzer | 2019-10-22 22:55:13 | Re: jsonb_set() strictness considered harmful to data |
From | Date | Subject | |
---|---|---|---|
Next Message | Peter J. Holzer | 2019-10-22 23:11:24 | Re: jsonb_set() strictness considered harmful to data |
Previous Message | Peter J. Holzer | 2019-10-22 22:55:13 | Re: jsonb_set() strictness considered harmful to data |