Re: jsonb - jsonb operators
От | Glyn Astill |
---|---|
Тема | Re: jsonb - jsonb operators |
Дата | |
Msg-id | 580613357.11318000.1453144345944.JavaMail.yahoo@mail.yahoo.com обсуждение исходный текст |
Ответ на | jsonb - jsonb operators (Glyn Astill <glynastill@yahoo.co.uk>) |
Список | pgsql-hackers |
-------------------------------------------- On Mon, 18/1/16, Tom Lane <tgl@sss.pgh.pa.us> wrote: Subject: Re: [HACKERS] jsonb - jsonb operatorsTo: "Dmitry Dolgov" <9erthalion6@gmail.com>Cc: "Glyn Astill" <glynastill@yahoo.co.uk>,"Merlin Moncure" <mmoncure@gmail.com>, "pgsql-hackers@postgresql.org" <pgsql-hackers@postgresql.org>Date:Monday, 18 January, 2016, 16:50Dmitry Dolgov <9erthalion6@gmail.com>writes:>> if there'sany future intention toadd a delete operator that removes>element/pair matches?>I think the operator (jsonb - jsonb)is logical because wehave a shallow> concatenation function(something like a "union" operation), but wehave> nothinglike "setdifference" and "intersection" functions.Actually, I> thought to implement thesefunctions (at least for jsonbx).But of course> this function should be quite simple andconsider only full key/value> matchingas a target.I amwaryof this proposal because it seems to be takinglittleaccount of the fact that there*already is* a jsonb minus operator,twoofthem in fact. For exampleregression=# select'["a","b","c"]'::jsonb- 'b'; ?column? ------------ ["a","c"](1row)regression=# select '{"a":1,"b":2}'::jsonb - 'b';?column? ----------{"a": 1}(1 row)The proposed full-matchsemanticsdon't seem to me to be consistent withthe way that the existing operator works.Another rather nasty problemisthat the latter case works at all,ie theparser will decide the unknown literal is "text"so that it canapply "jsonb-text", there being no other plausible choice. Iftherewere a "jsonb - jsonb"operator, the parser would prefer thatone, dueto its heuristic about assuming that an unknownliteral is of the sametype as the otheroperator input. So addingsuch an operator will almostcertainly break queries that work in 9.5. Maybe it's worth adding oneanyway, butI don'tthink the case for its usefulness has beenprovento the point where we should createcompatibility issues to get it. regards, tom lane In that case pehaps there is no need for an operator, but a function would be useful. Perhaps specifying the depth to deleteon like Dimitri's key versions do? I mocked up the top level version last year, like you say its trivial, but I find it useful. It's here https://github.com/glynastill/jsonb_delete
В списке pgsql-hackers по дате отправления: