Description:
When using json_replace(), '}' of the end disappear.
* I'm using JSON UDF from labs.mysql.com.
(mysql-json-udfs-0.2.0-labs-json-udfs-linux-glibc2.5-x86_64.tar.gz)
How to repeat:
mysql> create table json (id int auto_increment, col1 varchar(1000), primary key(id));
Query OK, 0 rows affected (0.03 sec)
mysql> insert into json(col1) values('{"id":1,"Name":"Farmer grandmas","price":50000,"Conditions":["farms",15]}');
Query OK, 1 row affected (0.00 sec)
mysql> select id,json_replace(col1,'Name','"grandmas"') from json where id=1;
+----+-------------------------------------------------------------------+
| id | json_replace(col1,'Name','"grandmas"') |
+----+-------------------------------------------------------------------+
| 1 | {"id":1,"Name":"grandmas","price":50000,"Conditions":["farms",15] |
+----+-------------------------------------------------------------------+
1 row in set (0.00 sec)
mysql>
======================================================
[Supplement]
The following case is no problem.
mysql> select id,json_replace(col1,'Conditions','1','20') from json where id=1;
+----+---------------------------------------------------------------------------+
| id | json_replace(col1,'Conditions','1','20') |
+----+---------------------------------------------------------------------------+
| 1 | {"id":1,"Name":"Farmer grandmas","price":50000,"Conditions":["farms",20]} |
+----+---------------------------------------------------------------------------+
1 row in set (0.00 sec)
Although json_set() doesn't be used the following, json_set() behaves same.
mysql> select id,json_set(col1,'Name','"grandmas"') from json where id=1;
+----+-------------------------------------------------------------------+
| id | json_set(col1,'Name','"grandmas"') |
+----+-------------------------------------------------------------------+
| 1 | {"id":1,"Name":"grandmas","price":50000,"Conditions":["farms",15] |
+----+-------------------------------------------------------------------+
1 row in set (0.00 sec)
======================================================
Suggested fix:
Don't cut '}' of the end.