Re: jsonb concatenate operator's semantics seem questionable

From: Peter Geoghegan <pg(at)heroku(dot)com>
To: Josh Berkus <josh(at)agliodbs(dot)com>
Cc: Ryan Pedela <rpedela(at)datalanche(dot)com>, Robert Haas <robertmhaas(at)gmail(dot)com>, Andrew Dunstan <andrew(at)dunslane(dot)net>, Dmitry Dolgov <9erthalion6(at)gmail(dot)com>, Petr Jelinek <petr(at)2ndquadrant(dot)com>, Pg Hackers <pgsql-hackers(at)postgresql(dot)org>, Ilya Ashchepkov <koctep(at)gmail(dot)com>
Subject: Re: jsonb concatenate operator's semantics seem questionable
Date: 2015-05-18 18:34:30
Message-ID: CAM3SWZQe4Motoc+ZB46N6--9b2r0Jpcbr=cTumLs1gWwJ702ng@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Mon, May 18, 2015 at 11:24 AM, Josh Berkus <josh(at)agliodbs(dot)com> wrote:
> On 05/17/2015 09:11 PM, Peter Geoghegan wrote:> As I said, I don't think
> that my preference for deep concatenation is
>> a matter of taste. I think that shallow concatenation is fundamentally
>> and objectively at odds with what jsonb is supposed to be (as long as
>> concatenation is the way "nested assignment" works, which is what
>> users have been taught to think).
>
> That was a really wordy way to not answer my question. Everyone wants
> deep append. We don't have it. Unless you have a finished, tested
> patch you're sitting on, that discussion isn't relevant with the sole
> exception of whether we want to reserve "||" for it.

The point of not using "||" is to distance this from the update hstore
idiom. It won't work here in the way I expected.

> On 05/18/2015 08:57 AM, Ryan Pedela wrote:
>> If not, deep concatenation would solve this problem, but I can also see
>> another solution. Use + for shallow concatenation since it really means
>> "add element to top-level path" as Peter suggests. Then add another
>> function: jsonb_add( target jsonb, path text[], new jsonb ) to add
>> element at any arbitrary path. Then leave || for deep concatenation in
>> 9.6 or whenever.
>
> Since swapping the operator seems still on the table, is there any
> particular reason why you think "+" is more suited to shallow
> concatination? Both you and Peter have said this, but as a heavy user
> of JSON/JSONB, to me it seems the other way around. That is, "+" says
> "add to arbitrary nested node" to me more than "||" does.

I'm not necessarily attached to "+". I just want to make this
different to hstore's "||" operator. There should be a similar idiom
with jsonb, but that can come later.

--
Peter Geoghegan

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Josh Berkus 2015-05-18 18:45:03 Re: jsonb concatenate operator's semantics seem questionable
Previous Message Peter Geoghegan 2015-05-18 18:30:45 Re: jsonb concatenate operator's semantics seem questionable