Re: Further issues with jsonb semantics, documentation
От | Peter Geoghegan |
---|---|
Тема | Re: Further issues with jsonb semantics, documentation |
Дата | |
Msg-id | CAM3SWZSfnbHnbjrcQp9udaHv2fTEtPm91pN7zWk=bQs5qnFmDw@mail.gmail.com обсуждение исходный текст |
Ответ на | Further issues with jsonb semantics, documentation (Peter Geoghegan <pg@heroku.com>) |
Список | pgsql-hackers |
On Wed, Jun 3, 2015 at 7:02 PM, Peter Geoghegan <pg@heroku.com> wrote: > Consider this case: > > postgres=# select '{"c":5, "a":6, "b":7}'::jsonb - 1; > ?column? > ------------------ > {"a": 6, "c": 5} > (1 row) > > Clearly anyone expecting the value "a" to be removed here would be in > for a surprise. Moreover, it is inconsistent with the established > behavior of the corresponding array-wise subscript operator: > > postgres=# select '{"c":5, "a":6, "b":7}'::jsonb -> 1; > ?column? > ---------- > [null] > (1 row) For similar reasons, I think that this inconsistency is unacceptable: postgres=# select '["a", "b", "c"]'::jsonb - -1; ?column? ------------["a", "b"] (1 row) postgres=# select '["a", "b", "c"]'::jsonb -> -1;?column? ----------[null] (1 row) jsonb now supports Python-style negative subscripting to index backward. I think that this a fine idea. However, I also think it's a big POLA violation that this was not done for the ordinary array subscripting operator ("operator jsonb -> integer") at the same time as "operator jsonb - integer" was added. Although doing this will require a compatibility note in the 9.5 release notes, it's extremely unlikely to destabilize anybody's app, and makes a lot of sense. -- Peter Geoghegan
В списке pgsql-hackers по дате отправления: