aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/backend/utils/adt/jsonpath_exec.c3
-rw-r--r--src/test/regress/expected/jsonb_jsonpath.out12
-rw-r--r--src/test/regress/sql/jsonb_jsonpath.sql1
3 files changed, 15 insertions, 1 deletions
diff --git a/src/backend/utils/adt/jsonpath_exec.c b/src/backend/utils/adt/jsonpath_exec.c
index ceb30033e1c..c30d059a762 100644
--- a/src/backend/utils/adt/jsonpath_exec.c
+++ b/src/backend/utils/adt/jsonpath_exec.c
@@ -1606,6 +1606,9 @@ executeItemOptUnwrapTarget(JsonPathExecContext *cxt, JsonPathItem *jsp,
JsonbValue jbv;
char *tmp = NULL;
+ if (unwrap && JsonbType(jb) == jbvArray)
+ return executeItemUnwrapTargetArray(cxt, jsp, jb, found, false);
+
switch (JsonbType(jb))
{
case jbvString:
diff --git a/src/test/regress/expected/jsonb_jsonpath.out b/src/test/regress/expected/jsonb_jsonpath.out
index c3f8e8249db..a6112e86fa7 100644
--- a/src/test/regress/expected/jsonb_jsonpath.out
+++ b/src/test/regress/expected/jsonb_jsonpath.out
@@ -2525,7 +2525,10 @@ select jsonb_path_query('null', '$.string()', silent => true);
(0 rows)
select jsonb_path_query('[]', '$.string()');
-ERROR: jsonpath item method .string() can only be applied to a bool, string, numeric, or datetime value
+ jsonb_path_query
+------------------
+(0 rows)
+
select jsonb_path_query('[]', 'strict $.string()');
ERROR: jsonpath item method .string() can only be applied to a bool, string, numeric, or datetime value
select jsonb_path_query('{}', '$.string()');
@@ -2576,6 +2579,13 @@ select jsonb_path_query('1234', '$.string().type()');
"string"
(1 row)
+select jsonb_path_query('[2, true]', '$.string()');
+ jsonb_path_query
+------------------
+ "2"
+ "true"
+(2 rows)
+
select jsonb_path_query('"2023-08-15 12:34:56 +5:30"', '$.timestamp().string()');
ERROR: cannot convert value from timestamptz to timestamp without time zone usage
HINT: Use *_tz() function for time zone support.
diff --git a/src/test/regress/sql/jsonb_jsonpath.sql b/src/test/regress/sql/jsonb_jsonpath.sql
index cbd2db533d4..5e14f7759bb 100644
--- a/src/test/regress/sql/jsonb_jsonpath.sql
+++ b/src/test/regress/sql/jsonb_jsonpath.sql
@@ -586,6 +586,7 @@ select jsonb_path_query('"1.23aaa"', '$.string()');
select jsonb_path_query('1234', '$.string()');
select jsonb_path_query('true', '$.string()');
select jsonb_path_query('1234', '$.string().type()');
+select jsonb_path_query('[2, true]', '$.string()');
select jsonb_path_query('"2023-08-15 12:34:56 +5:30"', '$.timestamp().string()');
select jsonb_path_query_tz('"2023-08-15 12:34:56 +5:30"', '$.timestamp().string()'); -- should work
select jsonb_path_query_array('[1.23, "yes", false]', '$[*].string()');