From: | Dmitry Dolgov <9erthalion6(at)gmail(dot)com> |
---|---|
To: | Thom Brown <thom(at)linux(dot)com> |
Cc: | Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: GSoC 2015: Extra Jsonb functionality |
Date: | 2015-03-20 13:26:31 |
Message-ID: | CA+q6zcWDbuSv3P98+nZHjA3zrra=v-fnqjG2UjVii4zmXbvwJQ@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
> Would this also be the case for this function?...
> # jsonb_add_to_path('{"b": {"c": ["d", "f"]}}'::jsonb, {b, c}::text[],
> '{"g":4}'::jsonb);
> jsonb_add_to_path
> ------------------------------------
> {"b": {"c": ["d", "f", {"g": 4}]}}
Yes, sure (the similar logic already implemented for the jsonb_concat).
On 20 March 2015 at 18:39, Thom Brown <thom(at)linux(dot)com> wrote:
> On 20 March 2015 at 11:21, Dmitry Dolgov <9erthalion6(at)gmail(dot)com> wrote:
> >> Perhaph it's my misunderstanding, but this would seem to be more of an
> >> intersection operation on keys rather than a delete.
> > Hm...why? We remove all elements, which are contains in the first and
> second
> > jsonb ("f": [4, 5] in this case) from the first one.
>
> On further thought, yes, I agree.
>
> >> Could there be a corresponding jsonb_except function which does the
> >> opposite (i.e. returns everything on the left side except where it
> matches
> >> with the right)?
> > and if I understand your question correctly, this is exactly what the
> > jsonb_delete_jsonb will do, isn't it?.
>
> Ah, yes, that's true.
>
> >> Is there a use-case for the example you've given above, where you take
> >> JSON containing objects and arrays, and flatten them out into a
> >> one-dimensional array?
> > Hm...actually I don't know about such use-cases. This function is analog
> of
> > the hstore_to_array (and the similar function hstore_to_matrix), which is
> > used sometimes, judging by github. So I thought this function should be
> > implemented (after this question I'm not so sure).
>
> Yeah, hstore was just key=>value, so flattening it out resulted in a
> simple {key,value,key,value} array. I don't think that's useful with
> json.
>
> >> What should happen if "g" or {"g"} were used instead?
> > Did you mean {"g": "key"}? Hmm...but in any case, I suppose this new
> object
> > should be appended to the array as a regular element.
> > =# jsonb_add_to_path('{"b": {"c": ["d", "f"]}}'::jsonb, {b,
> c}::text[],
> > '"g"'::jsonb);
> >
> > jsonb_add_to_path
> > ---------------------------------------
> > {"b": {"c": ["d", "f", "g"]}}
> >
>
> Would this also be the case for this function?...
>
> # jsonb_add_to_path('{"b": {"c": ["d", "f"]}}'::jsonb, {b, c}::text[],
> '{"g":4}'::jsonb);
> jsonb_add_to_path
> ------------------------------------
> {"b": {"c": ["d", "f", {"g": 4}]}}
>
> --
> Thom
>
From | Date | Subject | |
---|---|---|---|
Next Message | Andres Freund | 2015-03-20 13:26:37 | Re: configure can't detect proper pthread flags |
Previous Message | Alvaro Herrera | 2015-03-20 13:23:51 | Re: configure can't detect proper pthread flags |