jsonb concatenation loses properties on nested objects - Mailing list pgsql-bugs

From Phillip Haydon
Subject jsonb concatenation loses properties on nested objects
Date
Msg-id CAMa+EKB4hJ2q_JA1RC=ErstN9zi8=VqkSRTpX5LGCnwqZeTgng@mail.gmail.com
Whole thread Raw
Responses Re: jsonb concatenation loses properties on nested objects
List pgsql-bugs
I'm not sure if this is by design or not but I find it strange and believe
it's a bug.

If you concat two jsonb docs together, all first level properties are added
or modified.

Given:

select '{"FirstName": "Phillip"}'::jsonb || '{"LastName": "Haydon"}'::jsonb


You will get a result of:

{"LastName": "Haydon", "FirstName": "Phillip"}


However, if you have an object value with properties in that object that
differ between docs. The nested properties are lost.

select '{"User": {"FirstName": "Phillip"}}'::jsonb || '{"User":
{"LastName": "Haydon"}}'::jsonb


This results in:

{"User": {"LastName": "Haydon"}}


Based on the result of the first example I would have expected:

{"User": {"LastName": "Haydon", "FirstName": "Phillip"}}





Is this by design or is it a bug?


Thanks.


--

Kind Regards,
Phillip Haydon
www.philliphaydon.com

pgsql-bugs by date:

Previous
From: Tom Lane
Date:
Subject: Re: BUG #14217: Respect $CFLAGS from /usr/local/etc/config.site
Next
From: Dmitry Dolgov
Date:
Subject: Re: jsonb concatenation loses properties on nested objects