Re: jsonb - jsonb operators

From: Vitaly Burovoy <vitaly(dot)burovoy(at)gmail(dot)com>
To: Glyn Astill <glynastill(at)yahoo(dot)co(dot)uk>
Cc: "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: jsonb - jsonb operators
Date: 2016-01-18 22:56:40
Message-ID: CAKOSWN=oLL2_Ug8VECBZd5Qgvj84O9eFa2xPQ+3gUPgmyfR5fg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 1/15/16, Glyn Astill <glynastill(at)yahoo(dot)co(dot)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

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Andres Freund 2016-01-18 22:58:47 Re: [PATCH] Improve spinlock inline assembly for x86.
Previous Message Kevin Grittner 2016-01-18 22:56:22 Re: [PATCH] Improve spinlock inline assembly for x86.