Re: Patch bug: Fix jsonpath .* on Arrays

Поиск
Список
Период
Сортировка
От David G. Johnston
Тема Re: Patch bug: Fix jsonpath .* on Arrays
Дата
Msg-id CAKFQuwb=tJMm0NEn3NDVtzfaoNs73rcf3gbss7E5J9Lvns=y2w@mail.gmail.com
обсуждение исходный текст
Ответ на Patch bug: Fix jsonpath .* on Arrays  ("David E. Wheeler" <david@justatheory.com>)
Ответы Re: Patch bug: Fix jsonpath .* on Arrays
Список pgsql-hackers
On Tuesday, June 4, 2024, David E. Wheeler <david@justatheory.com> wrote:
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 for unwrapping arrays. The second example, however, just seems weird: this is .*, not .**.

This seems to be working correctly. Lax mode causes the first array level to unwrap and produce new context item values.  Then the wildcard member accessor is applied to each.  Numbers don’t have members so no matches exist in the first example.  The object in the second indeed has a single member and so matches the wildcard and its value, the array, is returned.

David J.

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

Предыдущее
От: "David E. Wheeler"
Дата:
Сообщение: Patch bug: Fix jsonpath .* on Arrays
Следующее
От: Wolfgang Walther
Дата:
Сообщение: Re: Build with LTO / -flto on macOS