Bug #70575 Implement JSON_SAFE_MERGE function
Submitted: 9 Oct 2013 19:32 Modified: 11 Dec 2013 18:14
Reporter: Sveta Smirnova Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: JSON User-defined function ( UDF ) Severity:S4 (Feature request)
Version:0.2 OS:Any
Assigned to: Sveta Smirnova CPU Architecture:Any

[9 Oct 2013 19:32] Sveta Smirnova
Description:
Currently JSON_MERGE does not check source and resulting documents for validity which leads to strange results.

How to repeat:
mysql> select json_merge('{"a":"b"}', '{true:"false"}' )\G
*************************** 1. row ***************************
json_merge('{"a":"b"}', '{true:"false"}' ): { "a": "b", "false"
 }

1 row in set (0.00 sec)

mysql> select json_merge('{"a":"b"}', '{"a":"b"}' )\G
*************************** 1. row ***************************
json_merge('{"a":"b"}', '{"a":"b"}' ): { "a": "b", "a": "b"
 }

1 row in set (0.00 sec)

Suggested fix:
Implement function JSON_SAFE_MERGE which will work slower, but will check documents for validity.
[11 Dec 2013 18:14] Sveta Smirnova
Posted by developer:
 
Fixed in version 0.3.0.

In addition JSON_MERGE now merges valid documents, containing arrays as root elements which are still not accepted by the parser (this was reported as bug #70567/17583282 and will be fixed in future versions).