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

From Andrew Dunstan
Subject Re: jsonb concatenate operator's semantics seem questionable
Date
Msg-id 555E4D2C.1040600@dunslane.net
Whole thread Raw
In response to Re: jsonb concatenate operator's semantics seem questionable  (Robert Haas <robertmhaas@gmail.com>)
Responses Re: jsonb concatenate operator's semantics seem questionable  (Jim Nasby <Jim.Nasby@BlueTreble.com>)
Re: jsonb concatenate operator's semantics seem questionable  (Peter Geoghegan <pg@heroku.com>)
List pgsql-hackers
On 05/21/2015 10:15 AM, Robert Haas wrote:
> On Wed, May 20, 2015 at 3:42 PM, Andres Freund <andres@anarazel.de> wrote:
>> On 2015-05-20 15:37:15 -0400, Tom Lane wrote:
>>> Josh Berkus <josh@agliodbs.com> writes:
>>>> That does cover all bases, and users would be able to create the
>>>> operator which suits their particular use case easily.  It's also fairly
>>>> similar to how jsquery works, although the syntax is completely different.
>>>> But ... it's after feature freeze.  So, thoughts?
>>> I think this could be seen as a correction/bug fix for a pre-freeze
>>> feature.  We should not be too resistant to filing down rough edges
>>> on new features, even if that involves a spec change.
>> +1
> +1, emphatically.
>


I appreciate your enthusiasm :-)

Here is a patch that renames jsonb_replace to jsonb_set with a boolean
create_missing flag that defaults to false (should we default it to
true?). With the flag set it's more or less upsert for jsonb. Without,
it's just update.

While the patch is sizable, it's mostly a) docs, b) regression changes,
and c) code changes from changing jsonb_replace to jsonb_set (and
replacePath to setPath in jsonfuncs.c). The actual significant code
changes are still quite small, around 200 lines.

I added a note in the docs to make the semantics of jsonb || jsonb much
more explicit.

This change really makes this set of jsonb features quite a bit more
compelling. I'm glad I thought of it - wish I had done so earlier. So
notwithstanding the controversy upthread, I think this is a good result.

cheers

andrew

Attachment

pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: GiST KNN Crasher
Next
From: Michael Paquier
Date:
Subject: Re: Float/Double cast to int