Re: jsonb_set() strictness considered harmful to data

Поиск
Список
Период
Сортировка
От rob stone
Тема Re: jsonb_set() strictness considered harmful to data
Дата
Msg-id d8d398e93e70d11bf0804142f608123f88698139.camel@gmail.com
обсуждение исходный текст
Ответ на Re: jsonb_set() strictness considered harmful to data  ("Peter J. Holzer" <hjp-pgsql@hjp.at>)
Список pgsql-general
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.





В списке pgsql-general по дате отправления:

Предыдущее
От: Maciek Sakrejda
Дата:
Сообщение: Re: jsonb_set() strictness considered harmful to data
Следующее
От: Maurice Aubrey
Дата:
Сообщение: Re: jsonb_set() strictness considered harmful to data