Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions mysql-test/main/func_json.result
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,46 @@ t1 CREATE TABLE `t1` (
`json_quote('foo')` varchar(38) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci
drop table t1;
select json_quote(17);
json_quote(17)
17
select json_quote(3.14);
json_quote(3.14)
3.14
select json_quote(1.5e2);
json_quote(1.5e2)
150
select json_quote(NULL);
json_quote(NULL)
null
select isnull(json_quote(NULL));
isnull(json_quote(NULL))
0
select json_quote('hello');
json_quote('hello')
"hello"
select json_quote('"already_quoted"');
json_quote('"already_quoted"')
"\"already_quoted\""
select json_contains(json_quote(NULL), 'null');
json_contains(json_quote(NULL), 'null')
1
create table t1 (a int);
insert into t1 values (NULL), (5);
select json_quote(a) from t1 order by a;
json_quote(a)
null
5
drop table t1;
select json_quote(NULL) is NULL;
json_quote(NULL) is NULL
0
select json_quote(NULL) = 'null';
json_quote(NULL) = 'null'
1
select coalesce(json_quote(NULL), 'fallback');
coalesce(json_quote(NULL), 'fallback')
null
select json_merge('string');
ERROR 42000: Incorrect parameter count in the call to native function 'json_merge'
select json_merge('string', 123);
Expand Down
31 changes: 31 additions & 0 deletions mysql-test/main/func_json.test
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,37 @@ select * from t1;
show create table t1;
drop table t1;

#
Comment thread
grooverdan marked this conversation as resolved.
# MDEV-13645 JSON_QUOTE should handle numeric and NULL arguments
#
# Integer literal: must return the unquoted number, not SQL NULL
select json_quote(17);
# Decimal literal: must return the unquoted decimal, not SQL NULL
select json_quote(3.14);
# Double/float literal: must return the unquoted value text, not SQL NULL
select json_quote(1.5e2);
# NULL input: must return the JSON null literal as a non-NULL string result
select json_quote(NULL);
Comment thread
grooverdan marked this conversation as resolved.
select isnull(json_quote(NULL));
# String regression: must still quote and escape exactly as before
select json_quote('hello');
select json_quote('"already_quoted"');
# JSON_QUOTE(NULL) must compose correctly inside another JSON function
# as the JSON null literal, not break the outer call with SQL NULL
select json_contains(json_quote(NULL), 'null');
# Column-sourced NULL: result must match literal NULL case (JSON null literal)
create table t1 (a int);
insert into t1 values (NULL), (5);
select json_quote(a) from t1 order by a;
drop table t1;
# SQL-NULL propagation checks: json_quote(NULL) must NOT propagate SQL NULL
# - IS NULL must return 0 (the string "null" is not SQL NULL)
select json_quote(NULL) is NULL;
# - equality with the string 'null' must return 1
select json_quote(NULL) = 'null';
# - COALESCE must return 'null', NOT 'fallback' (result is not SQL NULL)
select coalesce(json_quote(NULL), 'fallback');
Comment thread
grooverdan marked this conversation as resolved.

--error ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT
select json_merge('string');
select json_merge('string', 123);
Expand Down
2 changes: 2 additions & 0 deletions mysql-test/main/func_json_notembedded.result
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ select json_set(@arr,'$[1000]',1);
ERROR 70100: Query was interrupted: execution time limit 0.0001 sec exceeded
select json_valid(@arr);
ERROR 70100: Query was interrupted: execution time limit 0.0001 sec exceeded
select 1 member of (@arr);
ERROR 70100: Query was interrupted: execution time limit 0.0001 sec exceeded
select ST_AsTEXT(ST_GeomFromGeoJSON(JSON_OBJECT("type", "Point", "coordinates", @arr),2)) as exp;
ERROR 70100: Query was interrupted: execution time limit 0.0001 sec exceeded
select @obj IS JSON;
Expand Down
1 change: 1 addition & 0 deletions mysql-test/main/func_json_notembedded.test
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ select json_replace(@obj,'$.foo',1);
select json_schema_valid(@obj, '{"type":"object"}');
select json_set(@arr,'$[1000]',1);
select json_valid(@arr);
select 1 member of (@arr);
select ST_AsTEXT(ST_GeomFromGeoJSON(JSON_OBJECT("type", "Point", "coordinates", @arr),2)) as exp;
select @obj IS JSON;
select @arr IS JSON;
Expand Down
10 changes: 3 additions & 7 deletions mysql-test/suite/json/r/json_no_table.result
Original file line number Diff line number Diff line change
Expand Up @@ -2809,7 +2809,7 @@ select json_unquote('"abc"', NULL);
ERROR 42000: Incorrect parameter count in the call to native function 'json_unquote'
select json_quote(NULL);
json_quote(NULL)
NULL
null
select json_unquote(NULL);
json_unquote(NULL)
NULL
Expand Down Expand Up @@ -2854,11 +2854,9 @@ json_unquote('"')
"
Warnings:
Warning 4037 Unexpected end of JSON text in argument 1 to function 'json_unquote'
error ER_INCORRECT_TYPE
select json_quote(123);
json_quote(123)
NULL
error ER_INCORRECT_TYPE
123
select json_unquote(123);
json_unquote(123)
123
Expand Down Expand Up @@ -2939,7 +2937,6 @@ JSON_UNQUOTE( '"abc' )
"abc
Warnings:
Warning 4037 Unexpected end of JSON text in argument 1 to function 'json_unquote'
error ER_INCORRECT_TYPE
SELECT JSON_UNQUOTE( 123 );
JSON_UNQUOTE( 123 )
123
Expand Down Expand Up @@ -2976,10 +2973,9 @@ AS CHAR
SELECT JSON_QUOTE( 'abc' );
JSON_QUOTE( 'abc' )
"abc"
error ER_INCORRECT_TYPE
SELECT JSON_QUOTE( 123 );
JSON_QUOTE( 123 )
NULL
123
SELECT json_compact( JSON_QUOTE( '123' ));
json_compact( JSON_QUOTE( '123' ))
"123"
Expand Down
Loading
Loading