On 20 March 2015 at 11:21, Dmitry Dolgov <9erthali...@gmail.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 -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers