Re: GSoC 2015: Extra Jsonb functionality

Поиск
Список
Период
Сортировка
От Alvaro Herrera
Тема Re: GSoC 2015: Extra Jsonb functionality
Дата
Msg-id 20150319143505.GF3636@alvh.no-ip.org
обсуждение исходный текст
Ответ на Re: GSoC 2015: Extra Jsonb functionality  (Thom Brown <thom@linux.com>)
Ответы Re: GSoC 2015: Extra Jsonb functionality  (Thom Brown <thom@linux.com>)
Список pgsql-hackers
Thom Brown wrote:
> On 19 March 2015 at 14:12, Alvaro Herrera <alvherre@2ndquadrant.com> wrote:
> > Dmitry Dolgov wrote:
> >
> >>     * jsonb_slice - extract a subset of an jsonb
> >>       Example of usage:
> >>
> >>         =# jsonb_slice('{"a": 1, "b": {"c": 2}, "d": {"f": 3}}'::jsonb,
> >> ARRAY['b', 'f', 'x']);
> >>
> >>                jsonb_slice
> >>         ---------------------------
> >>           {"b": {"c": 2}, "f": 3}
> >
> > This is a bit strange.  Why did "f" get flattened out of "d"?  Is the
> > resulting document still valid for the purposes of an application using
> > it?  I think I'd expect the result to be {"b": {"c": 2}, "d": {"f": 3}}
> 
> Why would "d" be output when it wasn't in the requested slice?

Because it contains "f".

> Although I'm still a bit confused about "f" being produced.

I guess you could say that the second argument is an array of element
paths, not key names.  So to get the result I suggest, you would have to
use ARRAY['{b}', '{d,f}', '{x}'].  (Hm, this is a non-rectangular
array actually... I guess I'd go for ARRAY['b', 'd//f', 'x'] instead, or
whatever the convention is to specify a json path).

-- 
Álvaro Herrera                http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services



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

Предыдущее
От: Andres Freund
Дата:
Сообщение: Re: ERRCODE_T_R_DEADLOCK_DETECTED
Следующее
От: Amit Kapila
Дата:
Сообщение: Re: assessing parallel-safety