Bug #71180 JSON_CONTAINS_KEY founds not existent key in the array element
| Submitted: | 18 Dec 2013 21:51 | Modified: | 25 Dec 2013 13:25 |
|---|---|---|---|
| Reporter: | Sveta Smirnova | Email Updates: | |
| Status: | Closed | Impact on me: | |
| Category: | MySQL Server: JSON User-defined function ( UDF ) | Severity: | S3 (Non-critical) |
| Version: | 0.2.1, 0.3.0 | OS: | Any |
| Assigned to: | CPU Architecture: | Any |
[20 Dec 2013 17:43]
Sveta Smirnova
Same happens for following test case:
set @doc = '{"foo": {"foo": "bar"}, "baz": "bar"}';
select json_contains_key(@doc, 'baz', 'foo');
json_contains_key(@doc, 'baz', 'foo')
1
[25 Dec 2013 13:25]
Sveta Smirnova
Posted by developer: Fixed in versions 0.2.2 and 0.3.0
[25 Dec 2013 13:29]
Sveta Smirnova
Also fixed for JSON_EXTRACT, JSON_REMOVE, JSON_APPEND, JSON_REPLACE, JSON_SET
Portions of this website are copyright © 2001, 2002 The PHP Group
Page generated in 0.040 sec. using MySQL 8.4.7-u6-cloud
Timestamp references displayed by the system are UTC.
Content reproduced on this site is the property of the
respective copyright holders.
It is not reviewed in advance
by Oracle and does not necessarily represent the opinion of
Oracle or any other party.
Description: If an array element contains object, JSON_CONTAINS_KEY and companions search for the object elements as this object belongs to each of the array elements. How to repeat: set @doc = '{"foo": [{"foo": "bar"}, "baz"]}'; select json_contains_key(@doc, 'foo', 0, 'foo'); select json_contains_key(@doc, 'foo', 1, 'foo'); Result: select json_contains_key(@doc, 'foo', 0, 'foo'); json_contains_key(@doc, 'foo', 0, 'foo') 1 select json_contains_key(@doc, 'foo', 1, 'foo'); json_contains_key(@doc, 'foo', 1, 'foo') 1 Suggested fix: Expected result: select json_contains_key(@doc, 'foo', 0, 'foo'); json_contains_key(@doc, 'foo', 0, 'foo') 1 select json_contains_key(@doc, 'foo', 1, 'foo'); json_contains_key(@doc, 'foo', 1, 'foo') 0