]> git.8kb.co.uk Git - postgresql/pg_jsonb_opx/blob - sql/jsonb_opx.sql
Raise an error if un implemented append function called.
[postgresql/pg_jsonb_opx] / sql / jsonb_opx.sql
1 CREATE EXTENSION jsonb_opx VERSION '1.1';
2
3 -------------------------------------------------------------------------------
4 -- Tests for jsonb - text
5 -------------------------------------------------------------------------------
6
7 SELECT '["a", "b"]'::jsonb - 'b'::text;
8 SELECT '["a"]'::jsonb - 'b'::text;
9 SELECT '"a"'::jsonb - 'b'::text;
10 SELECT '[1]'::jsonb - 'b'::text;
11 SELECT '1'::jsonb - 'b'::text;
12 SELECT '["a", {"a":1}, "b"]'::jsonb - 'b'::text;
13
14 -- text deletion from array containers will only delete string elements
15 SELECT '[1, "1", "2", 2]'::jsonb - '2'::text;
16
17 -- simple text deletion from an object container
18 SELECT '{"a": 1, "b": 2, "c": 3}'::jsonb - 'b'::text;
19 SELECT '{"a": 1, "b": 2, "c": 3}'::jsonb - 'b '::text;
20 SELECT '{"a": 1, "b": 2, "c": {"b": 3}}'::jsonb - 'b'::text;
21 SELECT '{"a": 1, "b": 2, "c": {"b": [1,2,3]}}'::jsonb - 'b'::text;
22 SELECT '{"a": 1, "b": 2, "c":[1,2,3]}'::jsonb - 'b'::text;
23 SELECT '{"a": 1, "b": 2, "c":[1,2,3]}'::jsonb - 'c'::text;
24
25 -- simple text deletion from an object container should only match keys
26 SELECT '{"a": 1, "b": 2, "c": 3}'::jsonb - '3'::text;
27
28 -- deleting everything always results in an empty container
29 SELECT '["a"]'::jsonb - 'a'::text;
30 SELECT '{"a":1}'::jsonb - 'a'::text;
31
32 -- even for scalars, but this should perhaps error
33 SELECT '"a"'::jsonb - 'a'::text;
34
35 -- others
36 SELECT '["1", "2", true, false]'::jsonb - '2'::text;
37 SELECT '["1", "2", "2", "2"]'::jsonb - '2'::text;
38 SELECT '["a",2,{"a":1, "b":2}]'::jsonb - 'a'::text;
39 SELECT '{"a":{"b":3, "c":[1,2,3,4]}, "d":2}'::jsonb - 'a'::text;
40 SELECT '{"a":{"b":3, "c":[1,2,3,4]}, "d":2}'::jsonb - 'd'::text;
41 SELECT '{"a":{"b":3, "c":[1,2,3,4]}, "d":2}'::jsonb - 'b'::text;
42 SELECT '{"a":{"b":{"c":[1,[2,3,[4]],{"d":1}]}, "c":[1,2,3,4]}, "d":2}'::jsonb - 'a'::text;
43
44 -- function is strict, so - null returns null - assume SQL nulls and jsonb nulls are not equal anyway
45 SELECT '["1", "2", true, null]'::jsonb - null::text;
46
47 -------------------------------------------------------------------------------
48 -- Tests for jsonb - numeric
49 -------------------------------------------------------------------------------
50 -- Only matches numeric array element types
51 SELECT '[1, "1", "2", 2]'::jsonb - 2;
52 SELECT '[2]'::jsonb - 2;
53 SELECT '2'::jsonb - 2;
54
55 -- Does nothing for objects
56 SELECT '{"2":{"b":3, "c":[1,2,3,4]}, "d":2}'::jsonb - 2;
57
58 -------------------------------------------------------------------------------
59 -- Tests for jsonb - boolean
60 -------------------------------------------------------------------------------
61 -- Only matches boolean array element types
62 SELECT '[1, "1", false, true, null]'::jsonb - false;
63 SELECT '[1, "1", false, true, null]'::jsonb - true;
64
65 -------------------------------------------------------------------------------
66 -- Tests for jsonb - text[]
67 -------------------------------------------------------------------------------
68
69 -- text deletion from array containers will only delete string types currently
70 SELECT '[1, "1", "2", 2]'::jsonb - array['1','2'];
71
72 -- simple text[] deletion from an object container
73 SELECT '{"a": 1, "b": 2, "c": 3}'::jsonb - ARRAY['a','b'];
74 SELECT '{"a": 1, "b": 2, "c": 3}'::jsonb - ARRAY['a ','b ',' c'];
75 SELECT '{"a": 1, "b": 2, "c": 3}'::jsonb - ARRAY['a','b','c'];
76 SELECT '{"a": 1, "b": 2, "c": {"b": 3}}'::jsonb - ARRAY['a','b']; 
77 SELECT '{"a": 1, "b": 2, "c": {"b": [1,2,3]}}'::jsonb - ARRAY['a','b'];
78 SELECT '{"a": 1, "b": 2, "c":[1,2,3]}'::jsonb - ARRAY['a','b'];
79 SELECT '{"a": 1, "b": 2, "c":[1,2,3]}'::jsonb - ARRAY['a','c'];
80 SELECT '{"a":{"b":3, "c":[1,2,3,4]}, "d":2}'::jsonb - ARRAY['b','d'];
81 SELECT '{"a":{"b":3, "c":[1,2,3,4]}, "d":2}'::jsonb - ARRAY['b','a'];
82 SELECT '{"a":{"b":3, "c":[1,2,3,4]}, "d":2}'::jsonb - ARRAY['a','d'];
83 SELECT '{"a":{"b":3, "c":[1,{"r":[null,{"u":1}]},2,3,4]}, "d":2}'::jsonb - ARRAY['a','d'];
84 SELECT '{"a":{"b":3, "c":[1,{"r":[null,{"u":1}]},2,3,4]}, "d":[2,[2],[1,2,{"a":2},{"b":[1,[2]]}]]}'::jsonb - ARRAY['a'];
85 SELECT '{"a":{"b":3, "c":[1,{"r":[null,{"u":1}]},2,3,4]}, "d":[2,[2],[1,2,{"a":2},{"b":[1,[2]]}]]}'::jsonb - ARRAY['d'];
86 SELECT '{"a":{"b":{"c":[1,[2,3,[4]],{"d":1}]}, "c":[1,2,3,4]}, "d":2}'::jsonb - '{a}'::text[]; 
87
88 -- simple text[] deletion from an object container should only match keys
89 SELECT '{"a": 1, "b": 2, "c": 3}'::jsonb - ARRAY['1',' 2'];
90 SELECT '["a",2,{"a":1, "b":2}]'::jsonb - '{a}'::text[];
91
92 -- SQL nulls and jsonb nulls are not equal
93 SELECT '["1",null,2]'::jsonb - ARRAY[null];
94 SELECT '["1",2]'::jsonb - ARRAY[null];
95
96 -------------------------------------------------------------------------------
97 -- Tests for jsonb - numeric[]
98 -------------------------------------------------------------------------------
99 -- Only matches numeric array element types
100 SELECT '[1, "1", "2", 2]'::jsonb - ARRAY[2];
101 SELECT '[1, "1", "2", 2]'::jsonb - ARRAY[1,2];
102 SELECT '[2]'::jsonb  - ARRAY[1,2];
103 SELECT '2'::jsonb  - ARRAY[1,2];
104
105 -- Does nothing for objects
106 SELECT '{"2":{"b":3, "c":[1,2,3,4]}, "d":2}'::jsonb - ARRAY[1,2];
107
108 -------------------------------------------------------------------------------
109 -- Tests for jsonb - boolean[]
110 -------------------------------------------------------------------------------
111 -- Only matches boolean array element types
112 SELECT '[1, "1", false, true, null]'::jsonb - ARRAY[false];
113 SELECT '[1, "1", false, true, null]'::jsonb - ARRAY[true];
114 SELECT '[1, "1", false, true, null]'::jsonb - ARRAY[true, false];
115
116 -- Again nulls are not equal
117 SELECT '[1, "1", false, true, null]'::jsonb - ARRAY[true, false, null];
118
119 -------------------------------------------------------------------------------
120 -- Tests for jsonb - jsonb
121 -------------------------------------------------------------------------------
122
123 -- jsonb deletion from an object should match on key/value
124 SELECT '{"a": 1, "b": 2, "c": 3}'::jsonb - '{"a": 4, "b": 2}'::jsonb;
125
126 -- jsonb deletion from an array should only match on key
127 SELECT '["a", "b", "c"]'::jsonb - '{"a": 4, "b": 2}'::jsonb;
128
129 -- jsonb deletion from nested objects should not be part matched
130 SELECT '{"a": 4, "b": 2, "c": 3, "d": {"a": 4}}'::jsonb - '{"a": 4, "b": 2}'::jsonb;
131
132 -- but a match of all nested values should
133 SELECT '{"a": 4, "b": 2, "c": 3, "d": {"a": 4}}'::jsonb - '{"d": {"a": 4}, "b": 2}'::jsonb;
134 SELECT '{"a":{"b":{"c":[1,[2,3,[4]],{"d":1}]}, "c":[1,2,3,4]}, "d":2}'::jsonb - '{"d":2}'::jsonb;
135
136 -- jsonb nulls are equal
137 SELECT '{"a": 1, "b": 2, "c": null}'::jsonb - '{"a": 4, "c": null}'::jsonb;
138
139 -- others
140 SELECT '{"a": 4, "b": 2, "c": 3, "d": {"a": false}}'::jsonb - '{"d": {"a": false}, "b": 2}'::jsonb;
141 SELECT '{"a": "test", "b": 2.2, "c": {"a": false}}'::jsonb - '{"a": "test2", "c": {"a": false}, "b": 2.2}'::jsonb;
142 SELECT '{"a": "test", "b": 2.2, "c": {"a": false}, "d":true, "e":[1,2,"a"]}'::jsonb - '{"a": "test2", "b": 2.3, "c": {"a": true}, "d":false, "e":[1,2,3]}'::jsonb;
143 SELECT '{"a": "test", "b": 2.2, "c": {"a": false}, "d":true, "e":[1,2,"a"]}'::jsonb - '{"a": "test", "b": 2.3, "c": {"a": true}, "d":false, "e":[1,2,3]}'::jsonb;
144 SELECT '{"a": "test", "b": 2.2, "c": {"a": false}, "d":true, "e":[1,2,"a"]}'::jsonb - '{"a": "test2", "b": 2.2, "c": {"a": true}, "d":false, "e":[1,2,3]}'::jsonb;
145 SELECT '{"a": "test", "b": 2.2, "c": {"a": false}, "d":true, "e":[1,2,"a"]}'::jsonb - '{"a": "test2", "b": 2.3, "c": {"a": false}, "d":false, "e":[1,2,3]}'::jsonb;
146 SELECT '{"a": "test", "b": 2.2, "c": {"a": false}, "d":true, "e":[1,2,"a"]}'::jsonb - '{"a": "test2", "b": 2.3, "c": {"a": true}, "d":true, "e":[1,2,3]}'::jsonb;
147 SELECT '{"a": "test", "b": 2.2, "c": {"a": false}, "d":true, "e":[1,2,"a"]}'::jsonb - '{"a": "test2", "b": 2.3, "c": {"a": true}, "d":false, "e":[1,"a",2]}'::jsonb;
148 SELECT '{"a": "test", "b": 2.2, "c": {"a": false}, "d":true, "e":[1,2,"a"]}'::jsonb - '{"a": "test2", "b": 2.3, "c": {"a": true}, "d":false, "e":[1,2,"a"]}'::jsonb;
149 SELECT '{"a": "test", "b": 2.2, "c": {"a": false}, "d":true, "e":[1,2,"a"]}'::jsonb - '{"a": "test", "b": 2.2, "c": {"a": true}, "d":false, "e":[1,2,3]}'::jsonb;
150 SELECT '{"a": "test", "b": 2.2, "c": {"a": false}, "d":true, "e":[1,2,"a"]}'::jsonb - '{"a": "test", "b": 2.2, "c": {"a": false}, "d":false, "e":[1,2,3]}'::jsonb;
151 SELECT '{"a": "test", "b": 2.2, "c": {"a": false}, "d":true, "e":[1,2,"a"]}'::jsonb - '{"a": "test", "b": 2.2, "c": {"a": false}, "d":true, "e":[1,2,3]}'::jsonb;
152 SELECT '{"a": "test", "b": 2.2, "c": {"a": false}, "d":true, "e":[1,2,"a"]}'::jsonb - '{"a": "test", "b": 2.2, "c": {"a": false}, "d":true, "e":[1,2,"a"]}'::jsonb;
153 SELECT '["a",2,{"a":1, "b":2}]'::jsonb - '[[1]]'::jsonb;
154 SELECT '["a",2,{"a":1, "b":2}]'::jsonb - '[{"a":1}]'::jsonb;
155 SELECT '["a",2,{"a":1, "b":2}]'::jsonb - '[{"a":1, "b":2}]'::jsonb;
156 SELECT '["a",2,{"a":1, "b":2}]'::jsonb - '["a"]'::jsonb;
157 SELECT '["a",2,{"a":1, "b":2}]'::jsonb - '[2]'::jsonb;
158
159
160 -------------------------------------------------------------------------------
161 -- Tests for jsonb || jsonb
162 -------------------------------------------------------------------------------
163
164 -- duplicates should automatically be removed by lower level logic
165 SELECT '{"a": 1, "b": 2, "c": 3}'::jsonb || '{"a": 4, "b": 2, "d": 4}'::jsonb;
166 SELECT '{"a": 1, "b": null, "c": 3}'::jsonb || '{"a": 4, "b": null, "d": 4}'::jsonb;
167
168 -- concatentation of arrays
169 SELECT '["a", "b"]'::jsonb || '["c"]'::jsonb;
170
171 -- concatentation of scalars and arrays should be wrapped into arrays
172 SELECT '["a", "b"]'::jsonb || '"c"'::jsonb;
173
174 -- likewise concatentation of objects and arrays should be wrapped into arrays
175 SELECT '["a", "b"]'::jsonb || '{"a": 4, "b": 2}'::jsonb;
176
177 -- and all concatentation should be in natural order supplied
178 SELECT '{"a": 4, "b": 2}'::jsonb || '["a", "b"]'::jsonb || '["c", "d"]'::jsonb;
179
180 -- others
181 SELECT 'false'::jsonb || '["a", "b"]'::jsonb || '["c", "d"]'::jsonb;
182 SELECT '["a","b"]'::jsonb || '{"a":{"b":3, "c":[1,2,3,4]}, "d":2}'::jsonb;
183 SELECT '{"a":{"b":3, "c":[1,2,3,4]}, "d":2}'::jsonb || '["a","b"]'::jsonb;
184 SELECT '{"a":{"b":3, "c":[1,{"r":[null,{"u":1}]},2,3,4]}, "d":2}'::jsonb || '["a",["b","c",["3",1,2,[9,3,{"s":"o"},"x"]]],{"f":9}]'::jsonb;
185 SELECT'["a",["b","c",["3",1,2,[9,3,{"s":"o"},"x"]]],{"f":9}]'::jsonb || '["a",["b","c",["3",1,2,[9,3,{"s":"o"},"x"]]],{"f":9}]'::jsonb;
186 SELECT '{"a":{"b":3, "c":[1,{"r":[null,{"u":1}]},2,3,4]}, "d":2}'::jsonb || '{"a":{"b":3, "c":[1,{"r":[null,{"u":1}]},2,3,4]}, "d":2}'::jsonb;
187
188 -------------------------------------------------------------------------------
189 -- Tests for jsonb #= jsonb
190 -------------------------------------------------------------------------------
191
192 -- any keys existing in left argument have values replaced with those from righ 
193 -- argument
194 SELECT '{"a": 1}'::jsonb #= '{"a": [1,2,3,4]}'::jsonb;
195 SELECT '{"a": 1}'::jsonb #= '{"a": [1,2,3,4], "b":2}'::jsonb;
196 SELECT '{"a": 1, "b":1}'::jsonb #= '{"a": [1,2,3,4], "b":2}'::jsonb;
197
198 SELECT '{"a": 1, "b": 2, "c":[1,2,3], "d":{"test":false}}'::jsonb #= '{"a": [1,2,3,4], "b": {"f":100, "j":{"k":200}}, "c": 4, "d":{"test":true}}'::jsonb;
199
200 -- note that as we are matching only keys and replacing values operation on an 
201 -- scalar/array elements effectively does nothing 
202 SELECT '{"a":[1,2], "b":2, "c":12}'::jsonb #= '["a","b","c"]'::jsonb;
203 SELECT '{"a":[1,2], "b":2, "c":12}'::jsonb #= '[1,2,3]'::jsonb;
204 SELECT '[1,2,3]'::jsonb #= '[1,2,3,4]'::jsonb;
205 SELECT '"a"'::jsonb #= '{"a":1, "b":2}'::jsonb;
206 SELECT '{"a":1, "b":2}'::jsonb #= '"a"'::jsonb;
207 SELECT '{"a":{"b":3, "c":[1,{"r":[null,{"u":1}]},2,3,4]}, "d":2}'::jsonb  #= '{"a":{"b":3, "c":[1,{"r":[true,{"u":2}]},3,4,5]}}'::jsonb;
208 SELECT '["a","b","c"]'::jsonb #= '{"a":1}'::jsonb;
209
210 -------------------------------------------------------------------------------
211 -- Tests for jsonb #- text[] 
212 -------------------------------------------------------------------------------
213 SELECT '"a"'::jsonb #- ARRAY['b'];
214 SELECT '["a"]'::jsonb #- ARRAY['b'];
215 SELECT '{"a":1}'::jsonb #- ARRAY['b'];
216
217 SELECT '"a"'::jsonb #- ARRAY['a'];
218 SELECT '["a"]'::jsonb #- ARRAY['a'];
219 SELECT '{"a":1}'::jsonb #- ARRAY['a'];
220
221 SELECT '["a", "b"]'::jsonb #- ARRAY['a'];
222 SELECT '{"a":1, "b":2}'::jsonb #- ARRAY['a'];
223 SELECT '{"a":{"b":1}, "c":2}'::jsonb #- ARRAY['a'];
224
225 SELECT '{"a":[1,2,3,4], "b":2}'::jsonb #- ARRAY['a'];
226 SELECT '{"a":[1,2,3,4], "b":2}'::jsonb #- ARRAY['b'];
227
228 SELECT '{"a":{"b":[1,2,3,["a","b"]]}, "c":2}'::jsonb #- ARRAY['c'];
229 SELECT '{"a":{"b":[1,2,3,["a","b"]]}, "c":2}'::jsonb #- ARRAY['a'];
230 SELECT '{"a":{"b":[1,2,3,["a","b"]]}, "c":2}'::jsonb #- ARRAY['a','c'];
231 SELECT '{"a":{"b":[1,2,3,["a","b"]]}, "c":2}'::jsonb #- ARRAY['a','b'];
232 SELECT '{"a":{"b":[1,2,3,["a","b"]]}, "c":2}'::jsonb #- ARRAY['a','b','c'];
233 SELECT '{"a":{"b":{"c":1}, "c":[1,2,3,["a","b"]]}, "d":3}'::jsonb #- ARRAY['a','b','c'];
234
235 SELECT '{"a":{"b":[1,2,3,["a","b"]], "c":[1,2,3,4]}, "d":2}'::jsonb #- ARRAY['a','b'];
236 SELECT '{"a":{"b":[1,2,3,["a","b"]], "c":[1,2,3,4]}, "d":2}'::jsonb #- ARRAY['a','c'];
237 SELECT '{"a":{"b":[1,2,3,["a","b"]], "c":[1,2,3,4]}, "d":2}'::jsonb #- ARRAY['a',null];
238
239 SELECT '{"a":{"b":[1,2,3,["a",{"b":3}]], "c":[1,2,3,4]}, "d":2}'::jsonb #- ARRAY['a','b'];
240
241 SELECT '{"a":{"b":3, "d":[1,{"Z":[1,[2,3]]}]}}'::jsonb #- ARRAY['a','d'];
242
243 SELECT '["a", {"b":[1,2,3,4,5]}, 1, "c"]'::jsonb #- ARRAY['a'];
244 SELECT '["a", {"b":[1,2,3,4,5]}, 1, "c"]'::jsonb #- ARRAY['c'];
245 SELECT '[1,[2,[3,[4,[5,6,7]]]],"a","b"]'::jsonb #- ARRAY['b'];
246 SELECT '[1,[2,[3,[4,[5,6,7]]]],"a","b"]'::jsonb #- ARRAY['a'];
247 SELECT '{"a":{"b":3, "c":[1,{"r":[null,{"u":1}]},2,3,4]}, "d":2}'::jsonb #- ARRAY['a','b']; 
248 SELECT '{"a":{"b":3, "c":[1,{"r":[null,{"u":1}]},2,3,4]}, "d":2}'::jsonb #- ARRAY['a','c']; 
249 SELECT '{"a":{"b":3, "c":[1,{"r":[null,{"u":1}]},2,3,4]}, "d":2}'::jsonb #- ARRAY['a','d'];
250 SELECT '{"a":{"b":3, "c":[1,{"r":[null,{"u":1}]},2,3,4]}, "d":2}'::jsonb #- ARRAY['d'];
251 SELECT '{"a":{"b":3, "c":[1,{"r":[null,{"u":1}]},2,3,4]}, "d":2}'::jsonb #- ARRAY['a','c','r']; 
252 SELECT '{"a":{"b":3, "c":{"r":{"u":1}}}, "d":2}'::jsonb #- ARRAY['a','c','r'];  
253 SELECT '{"a":{"b":3, "c":{"r":{"u":1}}}, "d":2}'::jsonb #- ARRAY['a','c','r','u'];
254
255 -- expected limitation: cannot call with path deeper than 1 on a non-object
256 SELECT '["a", "b"]'::jsonb #- ARRAY['a','b'];
257
258 -------------------------------------------------------------------------------
259 -- Tests for jsonb_replace_path jsonb text[] 
260 -------------------------------------------------------------------------------
261
262 -- if the replacement on an object/array is passed as a scalar/array the value/element
263 -- is replaced
264 SELECT jsonb_replace_path('{"a":1, "b":2}', ARRAY['a'], '3'::jsonb);
265 SELECT jsonb_replace_path('{"a":1, "b":2}', ARRAY['a'], '[3]'::jsonb);
266 SELECT jsonb_replace_path('["a", "b"]', ARRAY['a'], '3'::jsonb);
267 SELECT jsonb_replace_path('["a", "b"]', ARRAY['a'], '[3]'::jsonb);
268 -- if the replacement on an object/array is passed as an object the whole key-value
269 -- pair is replaced.  This difference is perhaps confusing, but otherwise there is 
270 -- no way to directly replace a key without deletion and concatenation.
271 SELECT jsonb_replace_path('{"a":1, "b":2}', ARRAY['a'], '{"z":3}'::jsonb);
272 SELECT jsonb_replace_path('{"a":1, "b":2}', ARRAY['a'], '{"a":{"z":3}}'::jsonb);
273
274 SELECT jsonb_replace_path('{"a":1, "b":2}', ARRAY['a'], '{"f":3}'::jsonb);
275 SELECT jsonb_replace_path('{"a":{"b":1}}', ARRAY['a'], '{"f":3}'::jsonb);
276 SELECT jsonb_replace_path('{"a":{"b":1}}', ARRAY['a','b'], '{"f":3}'::jsonb);
277 SELECT jsonb_replace_path('{"a":{"b":1, "c":1}}', ARRAY['a','b'], '{"f":3}'::jsonb);
278 SELECT jsonb_replace_path('{"a":{"b":1, "c":1}}', ARRAY['a','c'], '{"f":3}'::jsonb);
279
280 SELECT jsonb_replace_path('{"a":{"b":1, "c":2, "d":[1,2]}}', ARRAY['a','b'], '{"f":3}'::jsonb);
281 SELECT jsonb_replace_path('{"a":{"b":1, "c":2, "d":[1,2]}}', ARRAY['a','c'], '{"f":3}'::jsonb);
282 SELECT jsonb_replace_path('{"a":{"b":1, "c":2, "d":[1,2]}}', ARRAY['a','d'], '{"f":3}'::jsonb);
283
284 SELECT jsonb_replace_path('{"a":{"d":[1,{"Z":[1,[2,3]]}]}}', ARRAY['a','d'], '{"f":3}'::jsonb);
285 SELECT jsonb_replace_path('{"a":{"b":1, "c":2, "d":[1,{"Z":[1,[2,3]]}]}}', ARRAY['a','b'], '{"f":3}'::jsonb);
286 SELECT jsonb_replace_path('{"a":{"b":1, "c":2, "d":[1,{"Z":[1,[2,3]]}]}}', ARRAY['a','c'], '{"f":3}'::jsonb);
287 SELECT jsonb_replace_path('{"a":{"b":1, "c":2, "d":[1,{"Z":[1,[2,3]]}]}}', ARRAY['a','d'], '{"f":3}'::jsonb);
288 SELECT jsonb_replace_path('{"a":1, "b":null, "c":[1,2,null], "c":{"d":11}, "e":{"20":[100,"c"]}}', ARRAY['c'], '{"f":[[1],2], "g":"test", "h":{"i":{"j":null}}}');
289
290 SELECT jsonb_replace_path('"a"', ARRAY['a'], '{"f":10}'::jsonb); 
291 SELECT jsonb_replace_path('"a"', ARRAY['z'], '{"f":10}'::jsonb); 
292 SELECT jsonb_replace_path('[null, "a"]', ARRAY[null], '"b"'::jsonb); 
293 SELECT jsonb_replace_path('[1,2,3,"4"]', ARRAY['4'], '"5"'::jsonb); 
294
295 SELECT jsonb_replace_path('{"a":{"b":3, "c":{"r":{"u":1}}}, "d":2}'::jsonb, ARRAY['a','c','r','u'],'{"a":{"b":3, "c":{"r":{"u":1}}}}'::jsonb);
296 SELECT jsonb_replace_path('{"a":{"b":3, "c":[1,{"r":[null,{"u":1}]},2,3,4]}, "d":2}'::jsonb, ARRAY['a','b'], '{"a":{"b":3, "c":{"r":{"u":1}}}}'::jsonb);