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