@@ -3882,9 +3882,9 @@ select json_pretty('{"a":["b", "c"], "d": {"e":"f"}}');
38823882(1 row)
38833883
38843884select json_concat('{"d": "test", "a": [1, 2]}', '{"g": "test2", "c": {"c1":1, "c2":2}}');
3885- json_concat
3886- -------------------------------------------------------------------
3887- {"a": [1, 2], "c": {"c1": 1, "c2": 2}, "d": "test", "g": "test2"}
3885+ json_concat
3886+ -----------------------------------------------------------------
3887+ {"a": [1, 2], "c": {"c1":1, "c2":2}, "d": "test", "g": "test2"}
38883888(1 row)
38893889
38903890select '{"aa":1 , "b":2, "cq":3}'::json || '{"cq":"l", "b":"g", "fg":false}';
@@ -4146,93 +4146,93 @@ select '["a","b","c"]'::json - -4;
41464146(1 row)
41474147
41484148select json_set('{"n":null, "a":1, "b":[1,2], "c":{"1":2}, "d":{"1":[2,3]}}'::json, '{n}', '[1,2,3]');
4149- json_set
4150- --------------------------------------------------------------------------
4151- {"a": 1, "b": [1, 2], "c": {"1": 2}, "d": {"1": [2, 3]}, "n": [1, 2, 3]}
4149+ json_set
4150+ --------------------------------------------------------------------
4151+ {"a": 1, "b": [1,2], "c": {"1":2}, "d": {"1":[2,3]}, "n": [1,2, 3]}
41524152(1 row)
41534153
41544154select json_set('{"n":null, "a":1, "b":[1,2], "c":{"1":2}, "d":{"1":[2,3]}}'::json, '{b,-1}', '[1,2,3]');
4155- json_set
4156- -----------------------------------------------------------------------------
4157- {"a": 1, "b": [1, [1, 2, 3]], "c": {"1": 2}, "d": {"1": [2, 3]}, "n": null}
4155+ json_set
4156+ ------------------------------------------------------------------------
4157+ {"a": 1, "b": [1, [1,2, 3]], "c": {"1":2}, "d": {"1":[2,3]}, "n": null}
41584158(1 row)
41594159
41604160select json_set('{"n":null, "a":1, "b":[1,2], "c":{"1":2}, "d":{"1":[2,3]}}'::json, '{d,1,0}', '[1,2,3]');
4161- json_set
4162- -----------------------------------------------------------------------------
4163- {"a": 1, "b": [1, 2], "c": {"1": 2}, "d": {"1": [[1, 2, 3], 3]}, "n": null}
4161+ json_set
4162+ -------------------------------------------------------------------------
4163+ {"a": 1, "b": [1,2], "c": {"1":2}, "d": {"1": [[1,2, 3], 3]}, "n": null}
41644164(1 row)
41654165
41664166select json_set('{"n":null, "a":1, "b":[1,2], "c":{"1":2}, "d":{"1":[2,3]}}'::json, '{d,NULL,0}', '[1,2,3]');
41674167ERROR: path element at position 2 is null
41684168select json_set('{"n":null, "a":1, "b":[1,2], "c":{"1":2}, "d":{"1":[2,3]}}'::json, '{n}', '{"1": 2}');
4169- json_set
4170- -------------------------------------------------------------------------
4171- {"a": 1, "b": [1, 2], "c": {"1": 2}, "d": {"1": [2, 3]}, "n": {"1": 2}}
4169+ json_set
4170+ ---------------------------------------------------------------------
4171+ {"a": 1, "b": [1,2], "c": {"1":2}, "d": {"1":[2,3]}, "n": {"1": 2}}
41724172(1 row)
41734173
41744174select json_set('{"n":null, "a":1, "b":[1,2], "c":{"1":2}, "d":{"1":[2,3]}}'::json, '{b,-1}', '{"1": 2}');
4175- json_set
4176- ----------------------------------------------------------------------------
4177- {"a": 1, "b": [1, {"1": 2}], "c": {"1": 2}, "d": {"1": [2, 3]}, "n": null}
4175+ json_set
4176+ -------------------------------------------------------------------------
4177+ {"a": 1, "b": [1, {"1": 2}], "c": {"1":2}, "d": {"1":[2,3]}, "n": null}
41784178(1 row)
41794179
41804180select json_set('{"n":null, "a":1, "b":[1,2], "c":{"1":2}, "d":{"1":[2,3]}}'::json, '{d,1,0}', '{"1": 2}');
4181- json_set
4182- ----------------------------------------------------------------------------
4183- {"a": 1, "b": [1, 2], "c": {"1": 2}, "d": {"1": [{"1": 2}, 3]}, "n": null}
4181+ json_set
4182+ --------------------------------------------------------------------------
4183+ {"a": 1, "b": [1,2], "c": {"1":2}, "d": {"1": [{"1": 2}, 3]}, "n": null}
41844184(1 row)
41854185
41864186select json_set('{"n":null, "a":1, "b":[1,2], "c":{"1":2}, "d":{"1":[2,3]}}'::json, '{d,NULL,0}', '{"1": 2}');
41874187ERROR: path element at position 2 is null
41884188select json_set('{"n":null, "a":1, "b":[1,2], "c":{"1":2}, "d":{"1":[2,3]}}'::json, '{b,-1}', '"test"');
4189- json_set
4190- --------------------------------------------------------------------------
4191- {"a": 1, "b": [1, "test"], "c": {"1": 2}, "d": {"1": [2, 3]}, "n": null}
4189+ json_set
4190+ -----------------------------------------------------------------------
4191+ {"a": 1, "b": [1, "test"], "c": {"1":2}, "d": {"1":[2,3]}, "n": null}
41924192(1 row)
41934193
41944194select json_set('{"n":null, "a":1, "b":[1,2], "c":{"1":2}, "d":{"1":[2,3]}}'::json, '{b,-1}', '{"f": "test"}');
4195- json_set
4196- ---------------------------------------------------------------------------------
4197- {"a": 1, "b": [1, {"f": "test"}], "c": {"1": 2}, "d": {"1": [2, 3]}, "n": null}
4195+ json_set
4196+ ------------------------------------------------------------------------------
4197+ {"a": 1, "b": [1, {"f": "test"}], "c": {"1":2}, "d": {"1":[2,3]}, "n": null}
41984198(1 row)
41994199
42004200select json_delete_path('{"n":null, "a":1, "b":[1,2], "c":{"1":2}, "d":{"1":[2,3]}}', '{n}');
4201- json_delete_path
4202- ----------------------------------------------------------
4203- {"a": 1, "b": [1, 2], "c": {"1": 2}, "d": {"1": [2, 3]}}
4201+ json_delete_path
4202+ ------------------------------------------------------
4203+ {"a": 1, "b": [1,2], "c": {"1":2}, "d": {"1":[2,3]}}
42044204(1 row)
42054205
42064206select json_delete_path('{"n":null, "a":1, "b":[1,2], "c":{"1":2}, "d":{"1":[2,3]}}', '{b,-1}');
4207- json_delete_path
4208- ------------------------------------------------------------------
4209- {"a": 1, "b": [1], "c": {"1": 2}, "d": {"1": [2, 3]}, "n": null}
4207+ json_delete_path
4208+ ---------------------------------------------------------------
4209+ {"a": 1, "b": [1], "c": {"1":2}, "d": {"1":[2,3]}, "n": null}
42104210(1 row)
42114211
42124212select json_delete_path('{"n":null, "a":1, "b":[1,2], "c":{"1":2}, "d":{"1":[2,3]}}', '{d,1,0}');
4213- json_delete_path
4214- ------------------------------------------------------------------
4215- {"a": 1, "b": [1, 2], "c": {"1": 2}, "d": {"1": [3]}, "n": null}
4213+ json_delete_path
4214+ ----------------------------------------------------------------
4215+ {"a": 1, "b": [1,2], "c": {"1":2}, "d": {"1": [3]}, "n": null}
42164216(1 row)
42174217
42184218select '{"n":null, "a":1, "b":[1,2], "c":{"1":2}, "d":{"1":[2,3]}}'::json #- '{n}';
4219- ?column?
4220- ----------------------------------------------------------
4221- {"a": 1, "b": [1, 2], "c": {"1": 2}, "d": {"1": [2, 3]}}
4219+ ?column?
4220+ ------------------------------------------------------
4221+ {"a": 1, "b": [1,2], "c": {"1":2}, "d": {"1":[2,3]}}
42224222(1 row)
42234223
42244224select '{"n":null, "a":1, "b":[1,2], "c":{"1":2}, "d":{"1":[2,3]}}'::json #- '{b,-1}';
4225- ?column?
4226- ------------------------------------------------------------------
4227- {"a": 1, "b": [1], "c": {"1": 2}, "d": {"1": [2, 3]}, "n": null}
4225+ ?column?
4226+ ---------------------------------------------------------------
4227+ {"a": 1, "b": [1], "c": {"1":2}, "d": {"1":[2,3]}, "n": null}
42284228(1 row)
42294229
42304230select '{"n":null, "a":1, "b":[1,2], "c":{"1":2}, "d":{"1":[2,3]}}'::json #- '{b,-1e}'; -- invalid array subscript
42314231ERROR: path element at position 2 is not an integer: "-1e"
42324232select '{"n":null, "a":1, "b":[1,2], "c":{"1":2}, "d":{"1":[2,3]}}'::json #- '{d,1,0}';
4233- ?column?
4234- ------------------------------------------------------------------
4235- {"a": 1, "b": [1, 2], "c": {"1": 2}, "d": {"1": [3]}, "n": null}
4233+ ?column?
4234+ ----------------------------------------------------------------
4235+ {"a": 1, "b": [1,2], "c": {"1":2}, "d": {"1": [3]}, "n": null}
42364236(1 row)
42374237
42384238-- empty structure and error conditions for delete and replace
@@ -4291,69 +4291,69 @@ select json_set('[]','{1}','"b"', false);
42914291-- json_set adding instead of replacing
42924292-- prepend to array
42934293select json_set('{"a":1,"b":[0,1,2],"c":{"d":4}}','{b,-33}','{"foo":123}');
4294- json_set
4295- -------------------------------------------------------
4296- {"a": 1, "b": [{"foo": 123}, 0, 1, 2], "c": {"d": 4}}
4294+ json_set
4295+ -----------------------------------------------------
4296+ {"a": 1, "b": [{"foo":123}, 0, 1, 2], "c": {"d":4}}
42974297(1 row)
42984298
42994299-- append to array
43004300select json_set('{"a":1,"b":[0,1,2],"c":{"d":4}}','{b,33}','{"foo":123}');
4301- json_set
4302- -------------------------------------------------------
4303- {"a": 1, "b": [0, 1, 2, {"foo": 123}], "c": {"d": 4}}
4301+ json_set
4302+ -----------------------------------------------------
4303+ {"a": 1, "b": [0, 1, 2, {"foo":123}], "c": {"d":4}}
43044304(1 row)
43054305
43064306-- check nesting levels addition
43074307select json_set('{"a":1,"b":[4,5,[0,1,2],6,7],"c":{"d":4}}','{b,2,33}','{"foo":123}');
4308- json_set
4309- ---------------------------------------------------------------------
4310- {"a": 1, "b": [4, 5, [0, 1, 2, {"foo": 123}], 6, 7], "c": {"d": 4}}
4308+ json_set
4309+ -------------------------------------------------------------------
4310+ {"a": 1, "b": [4, 5, [0, 1, 2, {"foo":123}], 6, 7], "c": {"d":4}}
43114311(1 row)
43124312
43134313-- add new key
43144314select json_set('{"a":1,"b":[0,1,2],"c":{"d":4}}','{c,e}','{"foo":123}');
4315- json_set
4316- ------------------------------------------------------------
4317- {"a": 1, "b": [0, 1, 2], "c": {"d": 4, "e": {"foo": 123}}}
4315+ json_set
4316+ ---------------------------------------------------------
4317+ {"a": 1, "b": [0,1, 2], "c": {"d": 4, "e": {"foo":123}}}
43184318(1 row)
43194319
43204320-- adding doesn't do anything if elements before last aren't present
43214321select json_set('{"a":1,"b":[0,1,2],"c":{"d":4}}','{x,-33}','{"foo":123}');
4322- json_set
4323- -----------------------------------------
4324- {"a": 1, "b": [0, 1, 2], "c": {"d": 4}}
4322+ json_set
4323+ --------------------------------------
4324+ {"a": 1, "b": [0,1, 2], "c": {"d":4}}
43254325(1 row)
43264326
43274327select json_set('{"a":1,"b":[0,1,2],"c":{"d":4}}','{x,y}','{"foo":123}');
4328- json_set
4329- -----------------------------------------
4330- {"a": 1, "b": [0, 1, 2], "c": {"d": 4}}
4328+ json_set
4329+ --------------------------------------
4330+ {"a": 1, "b": [0,1, 2], "c": {"d":4}}
43314331(1 row)
43324332
43334333-- add to empty object
43344334select json_set('{}','{x}','{"foo":123}');
4335- json_set
4336- ---------------------
4337- {"x": {"foo": 123}}
4335+ json_set
4336+ --------------------
4337+ {"x": {"foo":123}}
43384338(1 row)
43394339
43404340--add to empty array
43414341select json_set('[]','{0}','{"foo":123}');
4342- json_set
4343- ----------------
4344- [{"foo": 123}]
4342+ json_set
4343+ ---------------
4344+ [{"foo":123}]
43454345(1 row)
43464346
43474347select json_set('[]','{99}','{"foo":123}');
4348- json_set
4349- ----------------
4350- [{"foo": 123}]
4348+ json_set
4349+ ---------------
4350+ [{"foo":123}]
43514351(1 row)
43524352
43534353select json_set('[]','{-99}','{"foo":123}');
4354- json_set
4355- ----------------
4356- [{"foo": 123}]
4354+ json_set
4355+ ---------------
4356+ [{"foo":123}]
43574357(1 row)
43584358
43594359select json_set('{"a": [1, 2, 3]}', '{a, non_integer}', '"new_value"');
0 commit comments