Re: Avoid undesired flattening of jsonb arrays?

Поиск
Список
Период
Сортировка
От Joel Jacobson
Тема Re: Avoid undesired flattening of jsonb arrays?
Дата
Msg-id 358bd217-0891-4f9f-b82f-082bf139191d@www.fastmail.com
обсуждение исходный текст
Ответ на Re: Avoid undesired flattening of jsonb arrays?  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-general
The following nicer work-around was suggested to me by Andreas Karlsson:

-    jsonb_insert(x.jsonb_array,'{-1}',next_item.item,TRUE)
+    x.jsonb_array || jsonb_build_array(next_item.item)


On Fri, Dec 18, 2020, at 17:20, Tom Lane wrote:
"David G. Johnston" <david.g.johnston@gmail.com> writes:
> I'll agree that the description could discuss the case explicitly, and the
> array||scalar case could be added to the examples.

Yeah, the documentation completely fails to explain what happens
when the inputs aren't two arrays or two objects.  I'd kind of assumed
that that's an error, but it isn't.  Some experimentation indicates
that the behavior in all cases except two objects is to convert any
non-array input to a one-element array, reducing the situation to the
two-array case.

regards, tom lane



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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: Avoid undesired flattening of jsonb arrays?
Следующее
От: Tom Lane
Дата:
Сообщение: Re: Unexpected result count from update statement on partitioned table