From: | "David E(dot) Wheeler" <david(at)justatheory(dot)com> |
---|---|
To: | Chapman Flack <jcflack(at)acm(dot)org> |
Cc: | PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
Subject: | Re: jsonpath: Missing regex_like && starts with Errors? |
Date: | 2024-06-17 22:14:59 |
Message-ID: | 9BAFB50F-267E-4078-9558-36155E93A723@justatheory.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On Jun 16, 2024, at 11:52, David E. Wheeler <david(at)justatheory(dot)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 standard queries. 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 predicate expressions.
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 predicate expression. Because I keep confusing TF out of myself.
Best,
David
From | Date | Subject | |
---|---|---|---|
Next Message | David E. Wheeler | 2024-06-17 22:37:29 | Re: Proposal: Document ABI Compatibility |
Previous Message | Daniel Gustafsson | 2024-06-17 21:52:54 | Re: may be a buffer overflow problem |