Patch bug: Fix jsonpath .* on Arrays

Поиск
Список
Период
Сортировка
От David E. Wheeler
Тема Patch bug: Fix jsonpath .* on Arrays
Дата
Msg-id A95346F9-6147-46E0-809E-532A485D71D6@justatheory.com
обсуждение исходный текст
Ответы Re: Patch bug: Fix jsonpath .* on Arrays
Список pgsql-hackers
Hackers,

The behavior of the .* jpiAnyKey jsonpath selector seems incorrect.

```
select jsonb_path_query('[1,2,3]', '$.*');
jsonb_path_query
------------------
(0 rows)

select jsonb_path_query('[1,2,3,{"b": [3,4,5]}]', '$.*');
jsonb_path_query
------------------
[3, 4, 5]
```

The first example might be expected, since .* is intended for object keys, but the handing of `jpiAnyKey` has a branch
forunwrapping arrays. The second example, however, just seems weird: this is .*, not .**. 

The attached patch fixes it by passing the next node to `executeAnyItem()` (via `executeItemUnwrapTargetArray()`) and
thenproperly setting `jperOk` when `executeAnyItem()` finds values and there is no current (next) node. 

I took this approach given what appears to be the intended behavior or $* on arrays in lax mode. However, I could see
anargument that .* should not apply to arrays at all. If so, I can submit a new patch removing the branch that unwraps
anarray with .*. 

Best,

David


Вложения

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

Предыдущее
От: Alvaro Herrera
Дата:
Сообщение: Re: Revive num_dead_tuples column of pg_stat_progress_vacuum
Следующее
От: "David G. Johnston"
Дата:
Сообщение: Re: Patch bug: Fix jsonpath .* on Arrays