Re: bug in jsonb_set postgresql 5.5

From: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
To: Pascal Barbedor <pbarbedor(at)blset(dot)com>
Cc: Postgres Bug <pgsql-bugs(at)postgresql(dot)org>
Subject: Re: bug in jsonb_set postgresql 5.5
Date: 2018-02-22 16:02:18
Message-ID: CAKFQuwaUxXcWPi6p+JVo-6WuKc_7CJDswHHkvqh5KYp3OZwGow@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On Thu, Feb 22, 2018 at 8:51 AM, Pascal Barbedor <pbarbedor(at)blset(dot)com>
wrote:

> Thanks for the answer
>
> Where is this mentioned in the doc ?
>
> Since it is only a key inside the json object which is assigned the null
> value, does it mean it is impossible to have null values inside the jsonb
> object ?
>
>
​The docs don't indicate whether functions are strict or not (nor
apparently does psql's \df+)...but the behavior of strict functions is
documented (at least in CREATE FUNCTION for when you are creating your own).

It is indeed impossible to place an SQL NULL inside of a json object - you
can place a json null inside a json object though - thus you need to
convert from SQL NULL to json null explicitly (typically via COALESCE):

jsonb_set​(history, '{q1,obs}', COALESCE(to_jsonb(obs), 'null'))

David J.

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message PG Bug reporting form 2018-02-22 17:20:16 BUG #15077: Unable to receive data from WAL Stream Error
Previous Message Pascal Barbedor 2018-02-22 15:51:15 Re: bug in jsonb_set postgresql 5.5