pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Gianni Ceccarelli <dakkar@thenautilus.net>
To: pgsql-general@lists.postgresql.org
Subject: Re: Why does jsonb_set() remove non-mentioned keys?
Date: Thu, 4 Jul 2019 22:03:50 +0100
Message-ID: <20190704220350.514a15a5@thenautilus.net> (raw)
In-Reply-To: <qflnq9$86re$1@blaine.gmane.org>
References: <qfkua9$2q0e$1@blaine.gmane.org>
	<CAKFQuwaEErw0+DH6w+XwzbSMYiWdcRO5Bcy2ts_1C6FTB0TxMw@mail.gmail.com>
	<qflnq9$86re$1@blaine.gmane.org>

Some experimentation:

> \pset null '((null))'

> select jsonb_set('{"foo":1}'::jsonb,'{bar}','null'::jsonb,true);
┌─────────────────────────┐
│        jsonb_set        │
├─────────────────────────┤
│ {"bar": null, "foo": 1} │
└─────────────────────────┘


> select jsonb_set('{"foo":1}'::jsonb,'{bar}',to_jsonb(null::text),true);
┌───────────┐
│ jsonb_set │
├───────────┤
│ ((null))  │
└───────────┘

That's a bit weird already. Also:

> select null::jsonb;
┌──────────┐
│  jsonb   │
├──────────┤
│ ((null)) │
└──────────┘

> select 'null'::jsonb;
┌───────┐
│ jsonb │
├───────┤
│ null  │
└───────┘

> select to_jsonb(null::int);
┌──────────┐
│ to_jsonb │
├──────────┤
│ ((null)) │
└──────────┘

> select to_jsonb('null'::text);
┌──────────┐
│ to_jsonb │
├──────────┤
│ "null"   │
└──────────┘

I'm sharing Thomas's confusion…

-- 
	Dakkar - <Mobilis in mobile>
	GPG public key fingerprint = A071 E618 DD2C 5901 9574
	                             6FE2 40EA 9883 7519 3F88
	                    key id = 0x75193F88

Work continues in this area.
		-- DEC's SPR-Answering-Automaton





view thread (9+ messages)  latest in thread

Message-ID: <20190704220350.514a15a5@thenautilus.net>
Permalink:  ../20190704220350.514a15a5@thenautilus.net/
Also on:    postgresql.org/message-id/20190704220350.514a15a5@thenautilus.net

 · 

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: dakkar@thenautilus.net
  Subject: Re: Why does jsonb_set() remove non-mentioned keys?
  In-Reply-To: <20190704220350.514a15a5@thenautilus.net>
  References: <qfkua9$2q0e$1@blaine.gmane.org> <CAKFQuwaEErw0+DH6w+XwzbSMYiWdcRO5Bcy2ts_1C6FTB0TxMw@mail.gmail.com> <qflnq9$86re$1@blaine.gmane.org> <20190704220350.514a15a5@thenautilus.net>

* 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