Re: jsonb concatenate operator's semantics seem questionable - Mailing list pgsql-hackers

From Peter Geoghegan
Subject Re: jsonb concatenate operator's semantics seem questionable
Date
Msg-id CAM3SWZQ1zr9jezcCZFp7Da6U_J=abyy_Rv1=TUgwQsnFDHN_tA@mail.gmail.com
Whole thread Raw
In response to Re: jsonb concatenate operator's semantics seem questionable  (Petr Jelinek <petr@2ndquadrant.com>)
List pgsql-hackers
On Sun, May 17, 2015 at 7:16 AM, Petr Jelinek <petr@2ndquadrant.com> wrote:
> Agreed, if you look at jquery for example, the extend() method by default
> behaves like our current || and you have to specify that you want deep merge
> if you want the behavior described by Peter. So there is definitely point
> for both, at this time we just support only one of them, that's all.

The difference is that with jquery's extend(), you can easily
subscript the JSON document you're extending so that you do so for the
right nested object (without merging any containers the target
contains, but rather overwriting them with any of the source's
containers -- makes sense when you're explicit about the nesting level
like that). With jsonb, however, we're usually stuck with having to
write an SQL expression that evaluates to the final jsonb document
that we want (for UPDATE targetlist assignment, typically).

This is an enormous difference. We still don't have a way to update a
nested object's single field that I can see, and nested objects are
absolutely commonplace for the "document database" use case. So I
don't accept that this is a matter of individual preference or taste.
It's a big, practical distinction.

-- 
Peter Geoghegan



pgsql-hackers by date:

Previous
From: "David G. Johnston"
Date:
Subject: Re: Problems with question marks in operators (JDBC, ECPG, ...)
Next
From: Peter Geoghegan
Date:
Subject: Re: jsonb concatenate operator's semantics seem questionable