From 6840ba1b6a463c9fc6882c458b1feb77dc139da6 Mon Sep 17 00:00:00 2001 From: Florents Tselai Date: Tue, 17 Sep 2024 01:15:17 +0300 Subject: [PATCH v2 2/3] replace should work with strings inside arrays --- src/test/regress/expected/jsonb_jsonpath.out | 7 +++++-- src/test/regress/sql/jsonb_jsonpath.sql | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/test/regress/expected/jsonb_jsonpath.out b/src/test/regress/expected/jsonb_jsonpath.out index 2a1b2afff0..5c7da29102 100644 --- a/src/test/regress/expected/jsonb_jsonpath.out +++ b/src/test/regress/expected/jsonb_jsonpath.out @@ -2727,10 +2727,13 @@ select jsonb_path_query('null', '$.replace("x", "bye")', silent => true); ------------------ (0 rows) -select jsonb_path_query('[]', '$.replace("x", "bye")'); +select jsonb_path_query('["x", "y", "z"]', '$.replace("x", "bye")'); jsonb_path_query ------------------ -(0 rows) + "bye" + "y" + "z" +(3 rows) select jsonb_path_query('{}', '$.replace("x", "bye")'); ERROR: jsonpath item method .replace() can only be applied to a string diff --git a/src/test/regress/sql/jsonb_jsonpath.sql b/src/test/regress/sql/jsonb_jsonpath.sql index c1b8491387..63c5087149 100644 --- a/src/test/regress/sql/jsonb_jsonpath.sql +++ b/src/test/regress/sql/jsonb_jsonpath.sql @@ -622,7 +622,7 @@ rollback; -- Test .replace() select jsonb_path_query('null', '$.replace("x", "bye")'); select jsonb_path_query('null', '$.replace("x", "bye")', silent => true); -select jsonb_path_query('[]', '$.replace("x", "bye")'); +select jsonb_path_query('["x", "y", "z"]', '$.replace("x", "bye")'); select jsonb_path_query('{}', '$.replace("x", "bye")'); select jsonb_path_query('[]', 'strict $.replace("x", "bye")', silent => true); select jsonb_path_query('{}', '$.replace("x", "bye")', silent => true); -- 2.39.3 (Apple Git-146)