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

From Josh Berkus
Subject Re: jsonb concatenate operator's semantics seem questionable
Date
Msg-id 555A4744.9020208@agliodbs.com
Whole thread Raw
In response to jsonb concatenate operator's semantics seem questionable  (Peter Geoghegan <pg@heroku.com>)
Responses Re: jsonb concatenate operator's semantics seem questionable
List pgsql-hackers
On 05/18/2015 01:04 PM, Ryan Pedela wrote:
> Let me back up a little. I always like to think about what is the ideal
> interface first and then worry about implementation because
> implementation can always be changed but interface can't. I think the
> current concat/merge interface is the ideal. It should be || because
> that means concat/merge everywhere else in the PG interface that I am
> aware of. In the case of JSON which is a hierarchically data structure,
> it should be implemented as a deep merge which by definition satisfies a
> shallow merge. This is what I would expect as a user and I would think
> there was a bug if it didn't perform deep merge. I expect this because I
> can implement shallow merge easily myself using Javascript, Python, etc
> but deep merge is non-trivial. Therefore I would expect a special JSON
> concat/merge library function to do deep merge. I would rather the
> interface stay the same and it documented that the current
> implementation is a shallow merge and may become a deep merge in the future.
> 
> In the context of splitting shallow and deep merge into two operators, I
> think + is better for shallow and || better for deep. The reason for +
> is because many programming languages have this behavior. If I see the
> below code in language I have never used before:
> 
> objC = objA + objB
> 
> My default assumption is that + performs a shallow merge. Like I said, I
> would rather there just be one operator.

Thank you, that helps.  Anyone else?

-- 
Josh Berkus
PostgreSQL Experts Inc.
http://pgexperts.com



pgsql-hackers by date:

Previous
From: Ryan Pedela
Date:
Subject: Re: jsonb concatenate operator's semantics seem questionable
Next
From: Marko Tiikkaja
Date:
Subject: Re: jsonb concatenate operator's semantics seem questionable