mirror of
https://github.com/MariaDB/server.git
synced 2025-01-16 12:02:42 +01:00
MDEV-13324 JSON_SET returns NULL instead of object.
Superfluous ',' was added to the JSON_SET result so it became invalid.
This commit is contained in:
parent
49878be331
commit
467acc2119
4 changed files with 14 additions and 3 deletions
|
@ -680,3 +680,6 @@ JSON_OBJECT('foo', '`')
|
|||
SELECT JSON_OBJECT("foo", "bar`bar");
|
||||
JSON_OBJECT("foo", "bar`bar")
|
||||
{"foo": "bar`bar"}
|
||||
SELECT JSON_SET('{}', '$.age', 87);
|
||||
JSON_SET('{}', '$.age', 87)
|
||||
{"age": 87}
|
||||
|
|
|
@ -2109,10 +2109,9 @@ ERROR 42000: Incorrect parameter count in the call to native function 'json_set'
|
|||
error ER_INVALID_JSON_TEXT_IN_PARAM
|
||||
SELECT JSON_SET('{}', '$.name', JSON_EXTRACT('', '$'));
|
||||
JSON_SET('{}', '$.name', JSON_EXTRACT('', '$'))
|
||||
NULL
|
||||
{"name": null}
|
||||
Warnings:
|
||||
Warning 4037 Unexpected end of JSON text in argument 1 to function 'json_extract'
|
||||
Warning 4038 Syntax error in JSON text in argument 1 to function 'json_set' at position 2
|
||||
select json_set('[1,2,3]', '$[2]', 4);
|
||||
json_set('[1,2,3]', '$[2]', 4)
|
||||
[1, 2, 4]
|
||||
|
|
|
@ -328,3 +328,8 @@ select JSON_EXTRACT('{"foo": "bar" foobar foo invalid ', '$.foo');
|
|||
SELECT JSON_OBJECT('foo', '`');
|
||||
SELECT JSON_OBJECT("foo", "bar`bar");
|
||||
|
||||
#
|
||||
# MDEV-13324 JSON_SET returns NULL instead of object.
|
||||
#
|
||||
SELECT JSON_SET('{}', '$.age', 87);
|
||||
|
||||
|
|
|
@ -2450,6 +2450,8 @@ String *Item_func_json_insert::val_str(String *str)
|
|||
}
|
||||
else /*JSON_PATH_KEY*/
|
||||
{
|
||||
uint n_key= 0;
|
||||
|
||||
if (je.value_type != JSON_VALUE_OBJECT)
|
||||
continue;
|
||||
|
||||
|
@ -2461,6 +2463,7 @@ String *Item_func_json_insert::val_str(String *str)
|
|||
json_string_set_str(&key_name, lp->key, lp->key_end);
|
||||
if (json_key_matches(&je, &key_name))
|
||||
goto v_found;
|
||||
n_key++;
|
||||
if (json_skip_key(&je))
|
||||
goto js_error;
|
||||
break;
|
||||
|
@ -2478,7 +2481,8 @@ String *Item_func_json_insert::val_str(String *str)
|
|||
v_to= (const char *) (je.s.c_str - je.sav_c_len);
|
||||
str->length(0);
|
||||
if (append_simple(str, js->ptr(), v_to - js->ptr()) ||
|
||||
str->append(", \"", 3) ||
|
||||
(n_key > 0 && str->append(", ", 2)) ||
|
||||
str->append("\"", 1) ||
|
||||
append_simple(str, lp->key, lp->key_end - lp->key) ||
|
||||
str->append("\":", 2) ||
|
||||
append_json_value(str, args[n_arg+1], &tmp_val) ||
|
||||
|
|
Loading…
Reference in a new issue