Re: jsonb concatenate operator's semantics seem questionable

Поиск
Список
Период
Сортировка
От Robert Haas
Тема Re: jsonb concatenate operator's semantics seem questionable
Дата
Msg-id 311E4AE7-B47E-41D5-863C-E79AF8097AEB@gmail.com
обсуждение исходный текст
Ответ на jsonb concatenate operator's semantics seem questionable  (Peter Geoghegan <pg@heroku.com>)
Список pgsql-hackers
> On May 16, 2015, at 10:56 PM, Peter Geoghegan <pg@heroku.com> wrote:
>
> Another thing that I noticed about the new jsonb stuff is that the
> concatenate operator is based on the hstore one. This works as
> expected:
>
> postgres=# select '{"a":1}'::jsonb || '{"a":2}';
> ?column?
> ----------
> {"a": 2}
> (1 row)
>
> However, the nesting doesn't "match up" -- containers are not merged
> beyond the least-nested level:
>
> postgres=# select '{"a":{"nested":1}}'::jsonb || '{"a":{"also nested":2}}';
>         ?column?
> ---------------------------
> {"a": {"also nested": 2}}
> (1 row)
>
> This feels wrong to me. When jsonb was initially introduced, we took
> inspiration for the *containment* ("operator @> jsonb") semantics from
> hstore, but since jsonb is nested it worked in a nested fashion. At
> the top level and with no nested containers there was no real
> difference, but we had to consider the behavior of more nested levels
> carefully (the containment operator is clearly the most important
> jsonb operator). I had envisaged that with the concatenation of jsonb,
> concatenation would similarly behave in a nested fashion. Under this
> scheme, the above query would perform nested concatenation as follows:
>
> postgres=# select '{"a":{"nested":1}}'::jsonb || '{"a":{"also
> nested":2}}'; -- does not match actual current behavior
>         ?column?
> ---------------------------
> {"a": {"nested":1, "also nested": 2}}
> (1 row)

I'm not as much of a JSON user as some here, for sure, but for what it's worth my intuition here matches yours.

...Robert


В списке pgsql-hackers по дате отправления:

Предыдущее
От: Magnus Hagander
Дата:
Сообщение: Re: pg_audit documentation fixes
Следующее
От: David Rowley
Дата:
Сообщение: Re: PATCH: use foreign keys to improve join estimates v1