jsonpath_encoding.sql 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. --
  2. -- encoding-sensitive tests for jsonpath
  3. --
  4. -- We provide expected-results files for UTF8 (jsonpath_encoding.out)
  5. -- and for SQL_ASCII (jsonpath_encoding_1.out). Skip otherwise.
  6. SELECT getdatabaseencoding() NOT IN ('UTF8', 'SQL_ASCII')
  7. AS skip_test \gset
  8. \if :skip_test
  9. \quit
  10. \endif
  11. SELECT getdatabaseencoding(); -- just to label the results files
  12. -- checks for double-quoted values
  13. -- basic unicode input
  14. SELECT '"\u"'::jsonpath; -- ERROR, incomplete escape
  15. SELECT '"\u00"'::jsonpath; -- ERROR, incomplete escape
  16. SELECT '"\u000g"'::jsonpath; -- ERROR, g is not a hex digit
  17. SELECT '"\u0000"'::jsonpath; -- OK, legal escape
  18. SELECT '"\uaBcD"'::jsonpath; -- OK, uppercase and lower case both OK
  19. -- handling of unicode surrogate pairs
  20. select '"\ud83d\ude04\ud83d\udc36"'::jsonpath as correct_in_utf8;
  21. select '"\ud83d\ud83d"'::jsonpath; -- 2 high surrogates in a row
  22. select '"\ude04\ud83d"'::jsonpath; -- surrogates in wrong order
  23. select '"\ud83dX"'::jsonpath; -- orphan high surrogate
  24. select '"\ude04X"'::jsonpath; -- orphan low surrogate
  25. --handling of simple unicode escapes
  26. select '"the Copyright \u00a9 sign"'::jsonpath as correct_in_utf8;
  27. select '"dollar \u0024 character"'::jsonpath as correct_everywhere;
  28. select '"dollar \\u0024 character"'::jsonpath as not_an_escape;
  29. select '"null \u0000 escape"'::jsonpath as not_unescaped;
  30. select '"null \\u0000 escape"'::jsonpath as not_an_escape;
  31. -- checks for quoted key names
  32. -- basic unicode input
  33. SELECT '$."\u"'::jsonpath; -- ERROR, incomplete escape
  34. SELECT '$."\u00"'::jsonpath; -- ERROR, incomplete escape
  35. SELECT '$."\u000g"'::jsonpath; -- ERROR, g is not a hex digit
  36. SELECT '$."\u0000"'::jsonpath; -- OK, legal escape
  37. SELECT '$."\uaBcD"'::jsonpath; -- OK, uppercase and lower case both OK
  38. -- handling of unicode surrogate pairs
  39. select '$."\ud83d\ude04\ud83d\udc36"'::jsonpath as correct_in_utf8;
  40. select '$."\ud83d\ud83d"'::jsonpath; -- 2 high surrogates in a row
  41. select '$."\ude04\ud83d"'::jsonpath; -- surrogates in wrong order
  42. select '$."\ud83dX"'::jsonpath; -- orphan high surrogate
  43. select '$."\ude04X"'::jsonpath; -- orphan low surrogate
  44. --handling of simple unicode escapes
  45. select '$."the Copyright \u00a9 sign"'::jsonpath as correct_in_utf8;
  46. select '$."dollar \u0024 character"'::jsonpath as correct_everywhere;
  47. select '$."dollar \\u0024 character"'::jsonpath as not_an_escape;
  48. select '$."null \u0000 escape"'::jsonpath as not_unescaped;
  49. select '$."null \\u0000 escape"'::jsonpath as not_an_escape;