mirror of
https://github.com/MariaDB/server.git
synced 2025-08-01 03:47:19 +03:00
MDEV-13104 Json functions.
An extra ',' added to the JSON_MERGE result making it invalid.
This commit is contained in:
@ -683,3 +683,6 @@ JSON_OBJECT("foo", "bar`bar")
|
||||
SELECT JSON_SET('{}', '$.age', 87);
|
||||
JSON_SET('{}', '$.age', 87)
|
||||
{"age": 87}
|
||||
SELECT JSON_MERGE('[]', '{"c":"d"}');
|
||||
JSON_MERGE('[]', '{"c":"d"}')
|
||||
[{"c": "d"}]
|
||||
|
@ -333,3 +333,8 @@ SELECT JSON_OBJECT("foo", "bar`bar");
|
||||
#
|
||||
SELECT JSON_SET('{}', '$.age', 87);
|
||||
|
||||
#
|
||||
# MDEV-13104 Json functions.
|
||||
#
|
||||
SELECT JSON_MERGE('[]', '{"c":"d"}');
|
||||
|
||||
|
@ -1971,14 +1971,25 @@ continue_j2:
|
||||
else
|
||||
{
|
||||
const uchar *end1, *beg1, *end2, *beg2;
|
||||
int empty_array= 0;
|
||||
|
||||
beg1= je1->value_begin;
|
||||
|
||||
/* Merge as a single array. */
|
||||
if (je1->value_type == JSON_VALUE_ARRAY)
|
||||
{
|
||||
if (json_skip_level(je1))
|
||||
int cur_level= je1->stack_p;
|
||||
empty_array= 1;
|
||||
while (json_scan_next(je1) == 0)
|
||||
{
|
||||
if (je1->stack_p < cur_level)
|
||||
break;
|
||||
empty_array= 0;
|
||||
}
|
||||
|
||||
if (je1->s.error)
|
||||
return 1;
|
||||
|
||||
end1= je1->s.c_str - je1->sav_c_len;
|
||||
}
|
||||
else
|
||||
@ -1995,8 +2006,8 @@ continue_j2:
|
||||
end1= je1->value_end;
|
||||
}
|
||||
|
||||
if (str->append((const char*) beg1, end1 - beg1),
|
||||
str->append(", ", 2))
|
||||
if (str->append((const char*) beg1, end1 - beg1) ||
|
||||
(!empty_array && str->append(", ", 2)))
|
||||
return 3;
|
||||
|
||||
if (json_value_scalar(je2))
|
||||
|
Reference in New Issue
Block a user