jsonpath: Missing Binary Execution Path?
| От | David E. Wheeler |
|---|---|
| Тема | jsonpath: Missing Binary Execution Path? |
| Дата | |
| Msg-id | 551C85FD-C79C-4FCF-9563-014E74B41F70@justatheory.com обсуждение исходный текст |
| Ответы |
Re: jsonpath: Missing Binary Execution Path?
Re: jsonpath: Missing Binary Execution Path? |
| Список | pgsql-hackers |
Hackers,
Another apparent inconsistency I’ve noticed in jsonpath queries is the treatment of the && and || operators: They can’t
operateon scalar functions, only on other expressions. Some examples:
david=# select jsonb_path_query('true', '$ && $');
ERROR: syntax error at or near "&&" of jsonpath input
LINE 1: select jsonb_path_query('true', '$ && $');
^
david=# select jsonb_path_query('true', '$.boolean() && $.boolean()');
ERROR: syntax error at or near "&&" of jsonpath input
LINE 1: select jsonb_path_query('true', '$.boolean() && $.boolean()'...
^
The only place I’ve seen them work is inside filters with binary or unary operands:
jsonb_path_query('[1, 3, 7]', '$[*] ? (@ > 1 && @ < 5)');
jsonb_path_query
------------------
3
It doesn’t even work with boolean methods!
david=# select jsonb_path_query('[1, 3, 7]', '$[*] ? (@.boolean() && @.boolean())');
ERROR: syntax error at or near "&&" of jsonpath input
LINE 1: select jsonb_path_query('[1, 3, 7]', '$[*] ? (@.boolean() &&...
^
Other binary operators work just fine in these sorts of contexts:
david=# select jsonb_path_query('1', '$ >= 1');
jsonb_path_query
------------------
true
(1 row)
david=# select jsonb_path_query('[1, 3, 7]', '$[*] ? (@ > 1)');
jsonb_path_query
------------------
3
7
(2 rows)
Should && and || not also work on scalar operands?
Best,
David
В списке pgsql-hackers по дате отправления: