pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Thomas Kellerer <spam_eater@gmx.net>
To: pgsql-general@postgresql.org
Subject: Why does jsonb_set() remove non-mentioned keys?
Date: Thu, 4 Jul 2019 15:18:01 +0200
Message-ID: <qfkua9$2q0e$1@blaine.gmane.org> (raw)

Why does 

   select jsonb_set('{"foo": 1}'::jsonb, '{bar}', to_jsonb(null::int), true)

return NULL when all it should do is to add a second key?

I would expect {"foo": 1, "bar": null} or no change at all to the original JSON value, but not that the whole JSON is set to null. 

In the original case the new value to be set was the result of an expression, not a "hardcoded" null value.
 
Thomas








view thread (9+ messages)  latest in thread

Message-ID: <qfkua9$2q0e$1@blaine.gmane.org>
Permalink:  ../qfkua9$2q0e$1@blaine.gmane.org/
Also on:    postgresql.org/message-id/qfkua9$2q0e$1@blaine.gmane.org

 · 

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: spam_eater@gmx.net
  Subject: Re: Why does jsonb_set() remove non-mentioned keys?
  In-Reply-To: <qfkua9$2q0e$1@blaine.gmane.org>
  References: <qfkua9$2q0e$1@blaine.gmane.org>

* 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