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" writes:
> > I'll agree that the desc
"David G. Johnston" 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
tha
On Fri, Dec 18, 2020 at 8:24 AM Joel Jacobson wrote:
> The || operator for the jsonb type has a surprising behaviour.
>
> Instead of appending the right operand "as is" to the left operand,
> it has a magic behaviour if the right operand is an array,
> in which case it will append the items of th
The || operator for the jsonb type has a surprising behaviour.
Instead of appending the right operand "as is" to the left operand,
it has a magic behaviour if the right operand is an array,
in which case it will append the items of the array,
instead of appending the array itself as a single value
From: Victor Noagbodji [mailto:vnoagbo...@amplify-nation.com]
Sent: 28 June 2018 11:28
To: pgsql-general
Subject: JSONB arrays
Hey people,
I ended up with the following to check (or similar to return) the
intersection of two list of values on a JSONB object
Hey people,
I ended up with the following to check (or similar to return) the intersection
of two list of values on a JSONB object:
array_length(
array(
select jsonb_array_elements_text(col1)
intersect
select jsonb_array_elements_text(col2)
), 1) > 0
Is there a better way?
Thanks