Re: jsonpath: Missing regex_like && starts with Errors?

Поиск
Список
Период
Сортировка
От David E. Wheeler
Тема Re: jsonpath: Missing regex_like && starts with Errors?
Дата
Msg-id 9BAFB50F-267E-4078-9558-36155E93A723@justatheory.com
обсуждение исходный текст
Ответ на Re: jsonpath: Missing regex_like && starts with Errors?  ("David E. Wheeler" <david@justatheory.com>)
Ответы Re: jsonpath: Missing regex_like && starts with Errors?
Список pgsql-hackers
On Jun 16, 2024, at 11:52, David E. Wheeler <david@justatheory.com> wrote:

> I think that’s how it should be; I prefer that it raises errors by default but you can silence them:
>
> david=# select jsonb_path_query(target => '{"x": "hi"}', path => '$.integer()', silent => false);
> ERROR:  jsonpath item method .integer() can only be applied to a string or numeric value
>
> david=# select jsonb_path_query(target => '{"x": "hi"}', path => '$.integer()', silent => true);
> jsonb_path_query
> ------------------
> (0 rows)
>
> I suggest that the same behavior be adopted for `like_regex` and `starts with`.

Okay, I think I’ve figured this out, and the key is that I am, once again, comparing predicate path queries to SQL
standardqueries. If I update the first example to use a comparison I no longer get an error: 

david=# select jsonb_path_query('{"x": "hi"}', '$.integer() == 1');
 jsonb_path_query
------------------
 null

So I think that’s the key: There’s not a difference between the behavior of `like_regex` and `starts with` vs other
predicateexpressions. 

This dichotomy continues to annoy. I would very much like some way to have jsonb_path_query() raise an error (or even a
warning!)if passed a predate expression, and for jsonb_path_match() to raise an error or warning if its path is not a
predicateexpression. Because I keep confusing TF out of myself. 

Best,

David




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

Предыдущее
От: Daniel Gustafsson
Дата:
Сообщение: Re: may be a buffer overflow problem
Следующее
От: "David E. Wheeler"
Дата:
Сообщение: Re: Proposal: Document ABI Compatibility