jsonpath: Missing Binary Execution Path?
От
David E. Wheeler
Тема
jsonpath: Missing Binary Execution Path?
Дата
Msg-id
551C85FD-C79C-4FCF-9563-014E74B41F70@justatheory.com
Список
Дерево обсуждения
jsonpath: Missing Binary Execution Path? "David E. Wheeler" <david@justatheory.com>
Re: jsonpath: Missing Binary Execution Path? Chapman Flack <jcflack@acm.org>
Re: jsonpath: Missing Binary Execution Path? "David G. Johnston" <david.g.johnston@gmail.com>
Re: jsonpath: Missing Binary Execution Path? Chapman Flack <jcflack@acm.org>
Re: jsonpath: Missing Binary Execution Path? "David G. Johnston" <david.g.johnston@gmail.com>
Re: jsonpath: Missing Binary Execution Path? Chapman Flack <jcflack@acm.org>
Re: jsonpath: Missing Binary Execution Path? "David E. Wheeler" <david@justatheory.com>
Re: jsonpath: Missing Binary Execution Path? Chapman Flack <jcflack@acm.org>
Re: jsonpath: Missing Binary Execution Path? "David E. Wheeler" <david@justatheory.com>
Re: jsonpath: Missing Binary Execution Path? "David G. Johnston" <david.g.johnston@gmail.com>
Re: jsonpath: Missing Binary Execution Path? "David E. Wheeler" <david@justatheory.com>
Re: jsonpath: Missing Binary Execution Path? Andrew Dunstan <andrew@dunslane.net>
Re: jsonpath: Missing Binary Execution Path? "David E. Wheeler" <david@justatheory.com>
Hackers,
Another apparent inconsistency I’ve noticed in jsonpath queries is the treatment of the && and || operators: They can’t operate on 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 по дате отправления
От: Tom Lane
Дата: