Re: jsonb - jsonb operators - Mailing list pgsql-hackers

From Vitaly Burovoy
Subject Re: jsonb - jsonb operators
Date
Msg-id CAKOSWN=oLL2_Ug8VECBZd5Qgvj84O9eFa2xPQ+3gUPgmyfR5fg@mail.gmail.com
Whole thread Raw
In response to jsonb - jsonb operators  (Glyn Astill <glynastill@yahoo.co.uk>)
List pgsql-hackers
On 1/15/16, Glyn Astill <glynastill@yahoo.co.uk> wrote:
> Hi all,
>
> I was just looking through the new jsonb operators in the 9.5 release, and
> was wondering if there's any future intention to add a delete operator that
> removes element/pair matches?  I.e. some sort of top-level "jsonb - jsonb"
> operator, e.g.
>
>
> # select '{"a":1, "b":2}'::jsonb - '{"b":2, "a":4}'::jsonb;
> ?column?
> ----------
> {"a": 1}
> (1 row)
>
> Or would this behaviour be classed as incorrect in some way?
>
> Thanks
> Glyn

I thing the operator 'jsonb-jsonb' behavior in such case is not obvious.
How to understand the result is not like that:

# select '{"a":1, "b":2}'::jsonb - '{"b":2, "a":4}'::jsonb;
?column?
----------
{"a": -3, "b": 0}
(1 row)


P.S.: I guess an _operator_ jsonb+jsonb doesn't exist by the same way…
--
Best regards,
Vitaly Burovoy



pgsql-hackers by date:

Previous
From: Andres Freund
Date:
Subject: Re: [PATCH] Improve spinlock inline assembly for x86.
Next
From: Vitaly Burovoy
Date:
Subject: Re: custom function for converting human readable sizes to bytes