jsonpath: Missing regex_like && starts with Errors?

Поиск
Список
Период
Сортировка
От David E. Wheeler
Тема jsonpath: Missing regex_like && starts with Errors?
Дата
Msg-id 9272D3A9-8805-4DE1-A95F-84EB210EC121@justatheory.com
обсуждение исходный текст
Ответы Re: jsonpath: Missing regex_like && starts with Errors?
Список pgsql-hackers
Hackers,

I noticed that neither `regex_like` nor `starts with`, the jsonpath operators, raise an error when the operand is not a
string(or array of strings): 

david=# select jsonb_path_query('true', '$ like_regex "^hi"');
 jsonb_path_query
------------------
 null
(1 row)

david=# select jsonb_path_query('{"x": "hi"}', '$ starts with "^hi"');
 jsonb_path_query
------------------
 null
(1 row)

This is true in strict and lax mode, and with verbosity enabled (as in these examples). Most other operators raise an
errorwhen they can’t operate on the operand: 

david=# select jsonb_path_query('{"x": "hi"}', '$.integer()');
ERROR:  jsonpath item method .integer() can only be applied to a string or numeric value

david=# select jsonb_path_query('{"x": "hi"}', '$+$');
ERROR:  left operand of jsonpath operator + is not a single numeric value

Should `like_regex` and `starts with` adopt this behavior, too?

I note that filter expressions seem to suppress these sorts of errors, but I assume that’s by design:

david=# select jsonb_path_query('{"x": "hi"}', 'strict $ ?(@ starts with "^hi")');
 jsonb_path_query
------------------
(0 rows)

david=# select jsonb_path_query('{"x": "hi"}', 'strict $ ?(@ like_regex "^hi")');
 jsonb_path_query
------------------
(0 rows)

david=# select jsonb_path_query('{"x": "hi"}', 'strict $ ?(@.integer() == 1)');
 jsonb_path_query
------------------
(0 rows)

D




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

Предыдущее
От: Andres Freund
Дата:
Сообщение: Re: RFC: adding pytest as a supported test framework
Следующее
От: Andres Freund
Дата:
Сообщение: Re: Using LibPq in TAP tests via FFI