From: | Robert Haas <robertmhaas(at)gmail(dot)com> |
---|---|
To: | Peter Geoghegan <pg(at)heroku(dot)com> |
Cc: | Pg Hackers <pgsql-hackers(at)postgresql(dot)org>, Andrew Dunstan <andrew(at)dunslane(dot)net>, "koctep(at)gmail(dot)com" <koctep(at)gmail(dot)com> |
Subject: | Re: jsonb concatenate operator's semantics seem questionable |
Date: | 2015-05-17 12:07:15 |
Message-ID: | 311E4AE7-B47E-41D5-863C-E79AF8097AEB@gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
> On May 16, 2015, at 10:56 PM, Peter Geoghegan <pg(at)heroku(dot)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
From | Date | Subject | |
---|---|---|---|
Next Message | David Rowley | 2015-05-17 12:31:25 | Re: PATCH: use foreign keys to improve join estimates v1 |
Previous Message | Dmitriy Olshevskiy | 2015-05-17 11:46:50 | fix typos |