summaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2016-10-13 00:25:28 -0400
committerTom Lane <tgl@sss.pgh.pa.us>2016-10-13 00:25:48 -0400
commit9c4cc9e2c75e84a8267396be5cccbfe25b8f63f6 (patch)
tree267e982e1b0e833b465339644c94ce26b8244158 /src/test
parentccbb852cd6101e93976111676a90f1e5d9268951 (diff)
Fix broken jsonb_set() logic for replacing array elements.
Commit 0b62fd036 did a fairly sloppy job of refactoring setPath() to support jsonb_insert() along with jsonb_set(). In its defense, though, there was no regression test case exercising the case of replacing an existing element in a jsonb array. Per bug #14366 from Peng Sun. Back-patch to 9.6 where bug was introduced. Report: <20161012065349.1412.47858@wrigleys.postgresql.org>
Diffstat (limited to 'src/test')
-rw-r--r--src/test/regress/expected/jsonb.out6
-rw-r--r--src/test/regress/sql/jsonb.sql1
2 files changed, 7 insertions, 0 deletions
diff --git a/src/test/regress/expected/jsonb.out b/src/test/regress/expected/jsonb.out
index a6d25defb0d..e2cb08a6fba 100644
--- a/src/test/regress/expected/jsonb.out
+++ b/src/test/regress/expected/jsonb.out
@@ -3238,6 +3238,12 @@ select jsonb_set('[]','{1}','"b"', false);
[]
(1 row)
+select jsonb_set('[{"f1":1,"f2":null},2,null,3]', '{0}','[2,3,4]', false);
+ jsonb_set
+-------------------------
+ [[2, 3, 4], 2, null, 3]
+(1 row)
+
-- jsonb_set adding instead of replacing
-- prepend to array
select jsonb_set('{"a":1,"b":[0,1,2],"c":{"d":4}}','{b,-33}','{"foo":123}');
diff --git a/src/test/regress/sql/jsonb.sql b/src/test/regress/sql/jsonb.sql
index b84bd70a299..6b4c7969922 100644
--- a/src/test/regress/sql/jsonb.sql
+++ b/src/test/regress/sql/jsonb.sql
@@ -814,6 +814,7 @@ select '[]'::jsonb #- '{a}';
select jsonb_set('"a"','{a}','"b"'); --error
select jsonb_set('{}','{a}','"b"', false);
select jsonb_set('[]','{1}','"b"', false);
+select jsonb_set('[{"f1":1,"f2":null},2,null,3]', '{0}','[2,3,4]', false);
-- jsonb_set adding instead of replacing