Re: [PATH] Jsonb, insert a new value into an array at arbitrary position - Mailing list pgsql-hackers

From Tom Lane
Subject Re: [PATH] Jsonb, insert a new value into an array at arbitrary position
Date
Msg-id 8081.1459883293@sss.pgh.pa.us
Whole thread Raw
In response to Re: [PATH] Jsonb, insert a new value into an array at arbitrary position  (Andrew Dunstan <andrew@dunslane.net>)
Responses Re: [PATH] Jsonb, insert a new value into an array at arbitrary position  (Andrew Dunstan <andrew@dunslane.net>)
List pgsql-hackers
Andrew Dunstan <andrew@dunslane.net> writes:
> On 04/05/2016 12:42 PM, Teodor Sigaev wrote:
>> I'm agree about covering this case by tests, but I think it should be 
>> allowed.
>> In this case it will work exactly as jsbonb_set

> It seems to me a violation of POLA to allow something called "insert" to 
> do a "replace" instead.

I agree with Andrew's point here.  If the target is an array it would
never replace an entry, so why would it do so for an object?

I think there is potentially some use-case for insert-only semantics
for an object target, if you want to be sure you're not overwriting
data.  So I think "throw an error on duplicate key" is marginally better
than "reject object target altogether".  But I could live with either.
        regards, tom lane



pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: Endless loop calling PL/Python set returning functions
Next
From: Alvaro Herrera
Date:
Subject: Re: dealing with extension dependencies that aren't quite 'e'