Re: jsonb_set() strictness considered harmful to data

From: rob stone <floriparob(at)gmail(dot)com>
To: "Peter J(dot) Holzer" <hjp-pgsql(at)hjp(dot)at>, pgsql-general(at)lists(dot)postgresql(dot)org
Subject: Re: jsonb_set() strictness considered harmful to data
Date: 2019-10-24 01:52:36
Message-ID: d8d398e93e70d11bf0804142f608123f88698139.camel@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-hackers

Hello,

On Wed, 2019-10-23 at 20:33 +0200, Peter J. Holzer wrote:
>
> I grant that SQL NULL takes a bit to get used to. However, it is a
> core
> part of the SQL language and everyone who uses SQL must understand it
> (I
> don't remember when I first stumbled across "select * from t where c
> =
> NULL" returning 0 rows, but it was probably within the first few days
> of
> using a database). And personally I find it much easier to deal with
> concept which are applied consistently across the whole language than
> those which sometimes apply and sometimes don't seemingly at random,
> just because a developer thought it would be convenient for the
> specific
> use-case they had in mind.
>
> hp
>

From the JSON spec:-

3. Values

A JSON value MUST be an object, array, number, or string, or one of
the following three literal names:

false
null
true

The literal names MUST be lowercase. No other literal names are
allowed.

So, you can't set a value associated to a key to SQL NULL. If a key
should not have a value then delete that key from the JSON.

If you decide your application is going to use one of those three
literal names, then you need to code accordingly.

My 2 cents.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Maurice Aubrey 2019-10-24 02:18:45 Re: jsonb_set() strictness considered harmful to data
Previous Message Maciek Sakrejda 2019-10-24 01:00:19 Re: jsonb_set() strictness considered harmful to data

Browse pgsql-hackers by date

  From Date Subject
Next Message Maurice Aubrey 2019-10-24 02:18:45 Re: jsonb_set() strictness considered harmful to data
Previous Message Maciek Sakrejda 2019-10-24 01:00:19 Re: jsonb_set() strictness considered harmful to data