Re: Why does jsonb_set() remove non-mentioned keys?

From: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
To: Gianni Ceccarelli <dakkar(at)thenautilus(dot)net>
Cc: "pgsql-general(at)lists(dot)postgresql(dot)org" <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: Re: Why does jsonb_set() remove non-mentioned keys?
Date: 2019-07-04 21:42:40
Message-ID: CAKFQuwZWLNHw1=srVwe3c2X+5jjGOxv0rfaa9RuLk_Tu8zx8Hg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Thu, Jul 4, 2019 at 2:09 PM David G. Johnston <david(dot)g(dot)johnston(at)gmail(dot)com>
wrote:

> On Thursday, July 4, 2019, Gianni Ceccarelli <dakkar(at)thenautilus(dot)net>
> wrote:
>
>>
>> > select to_jsonb('null'::text);
>> ┌──────────┐
>> │ to_jsonb │
>> ├──────────┤
>> │ "null" │
>> └──────────┘
>>
>>
> Json null
>
>
Sorry, my bad on this last one. You cannot use to_jsonb to construct a
json null. The only way, I think, to construct a json null scalar is with
an explicit literal.

SELECT 'null'::jsonb;

The to_jsonb function always interprets a textual value passed to it as
being the literal text and so the original query results in a json string
whose content is "null"

David J.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Laurenz Albe 2019-07-05 07:21:44 Re: Converting to identity columns with domains on PK columns
Previous Message Adrian Klaver 2019-07-04 21:20:17 Re: Converting to identity columns with domains on PK columns