Re: Why does jsonb_set() remove non-mentioned keys? - Mailing list pgsql-general

From Gianni Ceccarelli
Subject Re: Why does jsonb_set() remove non-mentioned keys?
Date
Msg-id 20190704220350.514a15a5@thenautilus.net
Whole thread Raw
In response to Re: Why does jsonb_set() remove non-mentioned keys?  (Thomas Kellerer <spam_eater@gmx.net>)
Responses Re: Why does jsonb_set() remove non-mentioned keys?  ("David G. Johnston" <david.g.johnston@gmail.com>)
List pgsql-general
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



pgsql-general by date:

Previous
From: Adrian Klaver
Date:
Subject: Re: Converting to identity columns with domains on PK columns
Next
From: "David G. Johnston"
Date:
Subject: Re: Why does jsonb_set() remove non-mentioned keys?