From: | Thom Brown <thom(at)linux(dot)com> |
---|---|
To: | Dmitry Dolgov <9erthalion6(at)gmail(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 11:39:38 |
Message-ID: | CAA-aLv7JcWdQsd19H6OzJYyXJmK6ysw+fS0wy6hcouCU2cSW=w@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
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 | Robert Haas | 2015-03-20 12:00:33 | Re: Superuser connect during smart shutdown |
Previous Message | hitesh ramani | 2015-03-20 11:26:13 | Re: GSoC - Idea Discussion |