Re: jsonb concatenate operator's semantics seem questionable

From: Josh Berkus <josh(at)agliodbs(dot)com>
To: Ryan Pedela <rpedela(at)datalanche(dot)com>
Cc: Robert Haas <robertmhaas(at)gmail(dot)com>, Peter Geoghegan <pg(at)heroku(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 20:10:44
Message-ID: 555A4744.9020208@agliodbs.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Marko Tiikkaja 2015-05-18 20:15:33 Re: jsonb concatenate operator's semantics seem questionable
Previous Message Ryan Pedela 2015-05-18 20:04:56 Re: jsonb concatenate operator's semantics seem questionable