10
10
SELECT '"\u"'::jsonb; -- ERROR, incomplete escape
11
11
SELECT '"\u00"'::jsonb; -- ERROR, incomplete escape
12
12
SELECT '"\u000g"'::jsonb; -- ERROR, g is not a hex digit
13
SELECT '"\u0000"'::jsonb; -- OK, legal escape
13
SELECT '"\u0045"'::jsonb; -- OK, legal escape
14
SELECT '"\u0000"'::jsonb; -- ERROR, we don't support U+0000
14
15
-- use octet_length here so we don't get an odd unicode char in the
16
17
SELECT octet_length('"\uaBcD"'::jsonb::text); -- OK, uppercase and lower case both OK
156
157
SELECT '{"a":"b", "b":1, "c":null}'::jsonb @> '{"a":"b"}';
157
158
SELECT '{"a":"b", "b":1, "c":null}'::jsonb @> '{"a":"b", "c":"q"}';
160
SELECT '[1,2]'::jsonb @> '[1,2,2]'::jsonb;
161
SELECT '[1,1,2]'::jsonb @> '[1,2,2]'::jsonb;
162
SELECT '[[1,2]]'::jsonb @> '[[1,2,2]]'::jsonb;
163
SELECT '[1,2,2]'::jsonb <@ '[1,2]'::jsonb;
164
SELECT '[1,2,2]'::jsonb <@ '[1,1,2]'::jsonb;
165
SELECT '[[1,2,2]]'::jsonb <@ '[[1,2]]'::jsonb;
159
167
SELECT jsonb_contained('{"a":"b"}', '{"a":"b", "b":1, "c":null}');
160
168
SELECT jsonb_contained('{"a":"b", "c":null}', '{"a":"b", "b":1, "c":null}');
161
169
SELECT jsonb_contained('{"a":"b", "g":null}', '{"a":"b", "b":1, "c":null}');
366
374
SELECT jsonb '{ "a": "\ude04X" }' -> 'a'; -- orphan low surrogate
368
376
-- handling of simple unicode escapes
369
SELECT jsonb '{ "a": "the Copyright \u00a9 sign" }' ->> 'a' AS correct_in_utf8;
370
SELECT jsonb '{ "a": "dollar \u0024 character" }' ->> 'a' AS correct_everyWHERE;
371
SELECT jsonb '{ "a": "null \u0000 escape" }' ->> 'a' AS not_unescaped;
378
SELECT jsonb '{ "a": "the Copyright \u00a9 sign" }' as correct_in_utf8;
379
SELECT jsonb '{ "a": "dollar \u0024 character" }' as correct_everywhere;
380
SELECT jsonb '{ "a": "dollar \\u0024 character" }' as not_an_escape;
381
SELECT jsonb '{ "a": "null \u0000 escape" }' as fails;
382
SELECT jsonb '{ "a": "null \\u0000 escape" }' as not_an_escape;
384
SELECT jsonb '{ "a": "the Copyright \u00a9 sign" }' ->> 'a' as correct_in_utf8;
385
SELECT jsonb '{ "a": "dollar \u0024 character" }' ->> 'a' as correct_everywhere;
386
SELECT jsonb '{ "a": "dollar \\u0024 character" }' ->> 'a' as not_an_escape;
387
SELECT jsonb '{ "a": "null \u0000 escape" }' ->> 'a' as fails;
388
SELECT jsonb '{ "a": "null \\u0000 escape" }' ->> 'a' as not_an_escape;
373
390
-- jsonb_to_record and jsonb_to_recordset