Skip to content

Commit 6f6d053

Browse files
committed
MDEV-11439 No data type JSON, but CAST(something AS JSON) pretends to work
Use JSON_COMPACT(X) instead of CAST(X AS JSON). Bonus - X is validated to be a valid JSON. Fix a typo in the error message.
1 parent e0fa2ce commit 6f6d053

File tree

11 files changed

+636
-633
lines changed

11 files changed

+636
-633
lines changed

mysql-test/r/func_json.result

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -402,14 +402,14 @@ json_object("a", json_object("b", "abcd"))
402402
select json_object("a", '{"b": "abcd"}');
403403
json_object("a", '{"b": "abcd"}')
404404
{"a": "{\"b\": \"abcd\"}"}
405-
select json_object("a", cast('{"b": "abcd"}' as json));
406-
json_object("a", cast('{"b": "abcd"}' as json))
405+
select json_object("a", json_compact('{"b": "abcd"}'));
406+
json_object("a", json_compact('{"b": "abcd"}'))
407407
{"a": {"b": "abcd"}}
408-
select cast(NULL AS JSON);
409-
cast(NULL AS JSON)
408+
select json_compact(NULL);
409+
json_compact(NULL)
410410
NULL
411-
select json_depth(cast(NULL as JSON));
412-
json_depth(cast(NULL as JSON))
411+
select json_depth(json_compact(NULL));
412+
json_depth(json_compact(NULL))
413413
NULL
414414
select json_depth('[[], {}]');
415415
json_depth('[[], {}]')

0 commit comments

Comments
 (0)