Debian Codegraph @

mysql-test/suite/json/r/json_schema_validation_report.result

raw
1 # See that NULL-handling is correct
2 SELECT JSON_SCHEMA_VALIDATION_REPORT(NULL, NULL);
3 JSON_SCHEMA_VALIDATION_REPORT(NULL, NULL)
4 NULL
5 SELECT JSON_SCHEMA_VALIDATION_REPORT(JSON_OBJECT(), NULL);
6 JSON_SCHEMA_VALIDATION_REPORT(JSON_OBJECT(), NULL)
7 NULL
8 SELECT JSON_SCHEMA_VALIDATION_REPORT(NULL, JSON_OBJECT());
9 JSON_SCHEMA_VALIDATION_REPORT(NULL, JSON_OBJECT())
10 NULL
11 # A few "happy" cases
12 SELECT JSON_SCHEMA_VALIDATION_REPORT('{"type": "object"}', '{}');
13 JSON_SCHEMA_VALIDATION_REPORT('{"type": "object"}', '{}')
14 {"valid": true}
15 SELECT JSON_SCHEMA_VALIDATION_REPORT('{"type": "array"}', '[]');
16 JSON_SCHEMA_VALIDATION_REPORT('{"type": "array"}', '[]')
17 {"valid": true}
18 # Cases where the JSON document is invalid
19 SELECT JSON_SCHEMA_VALIDATION_REPORT('{"type": "object"}', '[]');
20 JSON_SCHEMA_VALIDATION_REPORT('{"type": "object"}', '[]')
21 {"valid": false, "reason": "The JSON document location '#' failed requirement 'type' at JSON Schema location '#'", "schema-location": "#", "document-location": "#", "schema-failed-keyword": "type"}
22 SELECT JSON_SCHEMA_VALIDATION_REPORT('{
23 "type": "object",
24 "properties": {
25 "geometry": {
26 "type": "object",
27 "properties": {
28 "latitude": {
29 "minimum": -90
30 }
31 }
32 }
33 }
34 }',
35 '{
36 "geometry": {
37 "longitude": -90,
38 "latitude": -180
39 }
40 }');
41 JSON_SCHEMA_VALIDATION_REPORT('{
42 "type": "object",
43 "properties": {
44 "geometry": {
45 "type": "object",
46 "properties": {
47 "latitude": {
48 "minimum": -90
49 }
50 }
51 }
52 }
53 }',
54 '{
55 "geometry": {
56 "longitude": -90,
57
58 {"valid": false, "reason": "The JSON document location '#/geometry/latitude' failed requirement 'minimum' at JSON Schema location '#/properties/geometry/properties/latitude'", "schema-location": "#/properties/geometry/properties/latitude", "document-location": "#/geometry/latitude", "schema-failed-keyword": "minimum"}
59 # A case where the JSON Schema is invalid
60 SELECT JSON_SCHEMA_VALIDATION_REPORT('{"type": "object-object"}', '{}');
61 JSON_SCHEMA_VALIDATION_REPORT('{"type": "object-object"}', '{}')
62 {"valid": false, "reason": "The JSON document location '#' failed requirement 'type' at JSON Schema location '#'", "schema-location": "#", "document-location": "#", "schema-failed-keyword": "type"}
63 # Non-json JSON Schema input
64 SELECT JSON_SCHEMA_VALIDATION_REPORT(POINT(1, 1), '{}');
65 ERROR 22032: Invalid data type for JSON data in argument 1 to function json_schema_validation_report; a JSON string or JSON type is required.
66 SELECT JSON_SCHEMA_VALIDATION_REPORT('{ bar', '{}');
67 ERROR 22032: Invalid JSON text in argument 1 to function json_schema_validation_report: "Missing a name for object member." at position 2.
68 # Non-object JSON Schema input
69 SELECT JSON_SCHEMA_VALIDATION_REPORT('[]', '{}');
70 ERROR 22032: Invalid JSON type in argument 1 to function json_schema_validation_report; an object is required.
71 # Non-json JSON document input
72 SELECT JSON_SCHEMA_VALIDATION_REPORT('{}', POINT(1, 1));
73 ERROR 22032: Invalid data type for JSON data in argument 2 to function json_schema_validation_report; a JSON string or JSON type is required.
74 SELECT JSON_SCHEMA_VALIDATION_REPORT('{}', '{ bar');
75 ERROR 22032: Invalid JSON text in argument 2 to function json_schema_validation_report: "Missing a name for object member." at position 2.
76 # Wrong argument count
77 SELECT JSON_SCHEMA_VALIDATION_REPORT();
78 ERROR 42000: Incorrect parameter count in the call to native function 'JSON_SCHEMA_VALIDATION_REPORT'
79 SELECT JSON_SCHEMA_VALIDATION_REPORT(NULL);
80 ERROR 42000: Incorrect parameter count in the call to native function 'JSON_SCHEMA_VALIDATION_REPORT'
81 SELECT JSON_SCHEMA_VALIDATION_REPORT(NULL, NULL, NULL);
82 ERROR 42000: Incorrect parameter count in the call to native function 'JSON_SCHEMA_VALIDATION_REPORT'
83 # Ensure that our item tree transformation doesn't get stuck forever when
84 # using prepared statements.
85 PREPARE stmt FROM 'SELECT JSON_SCHEMA_VALIDATION_REPORT(?, ''{}'') FROM DUAL';
86 SET @json_schema = '{"type":"object"}';
87 SET @null = NULL;
88 EXECUTE stmt USING @json_schema;
89 JSON_SCHEMA_VALIDATION_REPORT(?, '{}')
90 {"valid": true}
91 EXECUTE stmt USING @null;
92 JSON_SCHEMA_VALIDATION_REPORT(?, '{}')
93 NULL
94 EXECUTE stmt USING @json_schema;
95 JSON_SCHEMA_VALIDATION_REPORT(?, '{}')
96 {"valid": true}
97 #
98 # Bug#29529220: WL#13005: ASSERTION FAILURE: `!ARGS[0]->CONST_ITEM()'
99 # Bug#29528888: WL#11999: SIG6 IN ITEM_FUNC_JSON_SCHEMA_VALID::VAL_BOOL()
100 # AT ITEM_JSON_FUNC.CC
101 #
102 CREATE TABLE t1 (pk INT PRIMARY KEY, j JSON);
103 INSERT INTO t1 VALUES (1, '{"key": "foobar"}' );
104 SELECT JSON_SCHEMA_VALIDATION_REPORT(j, j) FROM t1 WHERE pk = 1;
105 JSON_SCHEMA_VALIDATION_REPORT(j, j)
106 {"valid": true}
107 SELECT JSON_SCHEMA_VALIDATION_REPORT(t2.j, t2.j)
108 FROM t1, (SELECT * FROM t1 WHERE pk = 1) t2;
109 JSON_SCHEMA_VALIDATION_REPORT(t2.j, t2.j)
110 {"valid": true}
111 DROP TABLE t1;
112 #
113 # Bug#30622327: JSON SCHEMA FUNCTIONS SHOULD CHECK ARGUMENT TYPES
114 # AT RESOLVE TIME
115 #
116 CREATE TABLE t(j JSON, g GEOMETRY);
117 PREPARE ps FROM 'SELECT * FROM t WHERE JSON_SCHEMA_VALIDATION_REPORT(j, g)';
118 ERROR 22032: Invalid data type for JSON data in argument 2 to function json_schema_validation_report; a JSON string or JSON type is required.
119 PREPARE ps FROM 'SELECT * FROM t WHERE JSON_SCHEMA_VALIDATION_REPORT(g, j)';
120 ERROR 22032: Invalid data type for JSON data in argument 1 to function json_schema_validation_report; a JSON string or JSON type is required.
121 DROP TABLE t;
122 #
123 # Bug#32047630: MISSING ERROR PROPAGATION IN JSON FUNCTIONS
124 #
125 SELECT JSON_ARRAY(JSON_SCHEMA_VALIDATION_REPORT('{}', '{'), 1);
126 ERROR 22032: Invalid JSON text in argument 2 to function json_schema_validation_report: "Missing a name for object member." at position 1.
127 SELECT JSON_ARRAY(JSON_SCHEMA_VALIDATION_REPORT('{}', CAST('{' AS JSON)), 1);
128 ERROR 22032: Invalid JSON text in argument 1 to function cast_as_json: "Missing a name for object member." at position 1.
129 SELECT JSON_ARRAY(JSON_SCHEMA_VALIDATION_REPORT(
130 CAST(CONCAT('{', RAND()) AS JSON), '{}'), 1);
131 ERROR 22032: Invalid JSON text in argument 1 to function cast_as_json: "Missing a name for object member." at position 1.