[MDEV-13306] JSON_CONTAINS returns wrong value Created: 2017-07-13  Updated: 2018-01-08  Resolved: 2017-10-05

Status: Closed
Project: MariaDB Server
Component/s: JSON
Affects Version/s: 10.2.6
Fix Version/s: 10.2.10

Type: Bug Priority: Major
Reporter: Diamond Lewis Assignee: Alexey Botchkov
Resolution: Fixed Votes: 0
Labels: None


 Description   

MariaDB 10.2

 
MariaDB [test]> SELECT JSON_CONTAINS('[{"a":"b"},{"c":"d"}]','{"c":"d"}');
+------------------------------------------------+ 
| JSON_CONTAINS('[{"a":"b"},{"c":"d"}]','{"c":"d"}') | 
+------------------------------------------------+ 
| 0 | 
+------------------------------------------------+ 
1 row in set (0.00 sec) 

MySQL 5.7

 
MySQL [test]> SELECT JSON_CONTAINS('[{"a":"b"},{"c":"d"}]','{"c":"d"}');
+------------------------------------------------+ 
| JSON_CONTAINS('[{"a":"b"},{"c":"d"}]','{"c":"d"}') | 
+------------------------------------------------+ 
| 1 | 
+------------------------------------------------+ 
1 row in set (0.00 sec) 



 Comments   
Comment by Alice Sherepa [ 2017-07-13 ]

confirmed on 10.2 and 10.3.
From mysql documentation: "A candidate nonarray is contained in a target array if and only if the candidate is contained in some element of the target. "
Also if object is on the first place in array, then function returns 1.

MariaDB [test]> select JSON_CONTAINS('[{"c":"d"},{"a":"b"}]','{"c":"d"}');
+----------------------------------------------------+
| JSON_CONTAINS('[{"c":"d"},{"a":"b"}]','{"c":"d"}') |
+----------------------------------------------------+
|                                                  1 |
+----------------------------------------------------+
1 row in set (0.00 sec)

Comment by Diamond Lewis [ 2017-09-20 ]

Hello, Just wondering if this issue has been fixed in another issue?

Thanks.

Comment by Alexey Botchkov [ 2017-10-05 ]

http://lists.askmonty.org/pipermail/commits/2017-October/011524.html

Comment by Diamond Lewis [ 2018-01-08 ]

Thanks a lot!

Generated at Thu Feb 08 08:04:32 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.