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@xxxxxx | management tools. __/ | http://www.hjp.at/ | -- Ross Anderson <https://www.edge.org/>
Attachment:
signature.asc
Description: PGP signature