Re: SQL/JSON path issues/questions
Alexander Korotkov <a.korotkov@postgrespro.ru>
From: Alexander Korotkov <a.korotkov@postgrespro.ru>
To: Kyotaro Horiguchi <horikyota.ntt@gmail.com>
Cc: Thom Brown <thom@linux.com>,
PostgreSQL-development <pgsql-hackers@postgresql.org>
Date: 2019-06-17T08:36:12Z
Lists: pgsql-hackers
Attachments
- 0001-implement-like_regex-flag-q-in-jsonpath-2.patch (application/octet-stream) patch 0001
- 0002-improve-jsonpath-like_regex-documentation-2.patch (application/octet-stream) patch 0002
- 0003-fix-jsonpath-varname-description-2.patch (application/octet-stream) patch 0003
I'm going to push attached 3 patches if no objections.
Regarding 0003-Separate-two-distinctive-json-errors.patch, I think it
requires more thoughts.
RETURN_ERROR(ereport(ERROR,
(errcode(ERRCODE_SINGLETON_JSON_ITEM_REQUIRED),
errmsg("left operand of jsonpath
operator %s is not a single numeric value",
- jspOperationName(jsp->type)))));
+ jspOperationName(jsp->type)),
+ (llen != 1 ?
+ errdetail("It was an array with %d
elements.", llen):
+ errdetail("The only element was not a
numeric.")))));
When we have more than 1 value, it's no exactly array. Jsonpath can
extract values from various parts of json document, which never
constitute and array. Should we say something like "There are %d
values"? Also, probably we should display the type of single element
if it's not numeric. jsonb_path_match() also throws
ERRCODE_SINGLETON_JSON_ITEM_REQUIRED, should we add similar
errdetail() there?
------
Alexander Korotkov
Postgres Professional: http://www.postgrespro.com
The Russian Postgres Company
Commits
-
Fixes for jsonpath filter expression elements table in docs
- 1ed89826b82c 12.0 landed
- 0cea6eb5a5f2 13.0 landed
-
Assorted fixes for jsonpath documentation
- a5c2f3a346fc 12.0 landed
- 5a7d697a3936 13.0 landed
-
Fix description for $varname jsonpath variable
- dfd79e2d0e8f 12.0 landed
-
Improve documentation for jsonpath like_regex predicate
- 1ff8dc9f19dd 12.0 landed
-
Support 'q' flag in jsonpath 'like_regex' predicate
- 261a5c192856 12.0 landed