Re: jsonb_set() strictness considered harmful to data

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: jsonb_set() strictness considered harmful to data
Дата
Msg-id 20073.1571948278@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: jsonb_set() strictness considered harmful to data  (Laurenz Albe <laurenz.albe@cybertec.at>)
Ответы Re: jsonb_set() strictness considered harmful to data  (Stuart McGraw <smcg4191@mtneva.com>)
Список pgsql-general
Laurenz Albe <laurenz.albe@cybertec.at> writes:
> On Wed, 2019-10-23 at 13:00 -0600, Stuart McGraw wrote:
>> It is less sensible with compound values where the rule can apply to
>> individual scalar components.

I agree that JSON can sensibly be viewed as a composite value, but ...

>>  And indeed that is what Postgresql does
>> for another compound type:
>> 
>> # select array_replace(array[1,2,3],2,NULL);
>> array_replace
>> ---------------
>> {1,NULL,3}
>> 
>> The returned value is not NULL.  Why the inconsistency between the array
>> type and json type?

... the flaw in this argument is that the array element is actually
a SQL NULL when we're done.  To do something similar in the JSON case,
we have to translate SQL NULL to JSON null, and that's cheating to
some extent.  They're not the same thing (and I'll generally resist
proposals to, say, make SELECT 'null'::json IS NULL return true).

Maybe it's okay to make this case work like that, but don't be too
high and mighty about it being logically clean; it isn't.

            regards, tom lane



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

Предыдущее
От: Jeff Lanzarotta
Дата:
Сообщение: Re: SQL Error [0A000]: ERROR: nondeterministic collations are notsupported for LIKE
Следующее
От: Andres Freund
Дата:
Сообщение: Re: EXPLAIN BUFFERS and I/O timing accounting questions