Bug #109893 json_contains always return 1 if candidate array is empty array
Submitted: 2 Feb 2023 9:15 Modified: 2 Feb 2023 10:06
Reporter: x j Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: JSON Severity:S3 (Non-critical)
Version:8.0.31, 8.0.32 OS:Any
Assigned to: CPU Architecture:Any

[2 Feb 2023 9:15] x j
Description:
as the title says, a little confused.
> A candidate array is contained in a target array if and only if every element in the candidate is contained in some element of the target.

NONE element is every element?

How to repeat:
mysql> select json_contains('["a",1]', '[]');
+--------------------------------+
| json_contains('["a",1]', '[]') |
+--------------------------------+
|                              1 |
+--------------------------------+
1 row in set (0.00 sec)

mysql> select json_contains('[]', '[]');
+---------------------------+
| json_contains('[]', '[]') |
+---------------------------+
|                         1 |
+---------------------------+
1 row in set (0.00 sec)

mysql> select json_contains('[1,2,3]', '[]');
+--------------------------------+
| json_contains('[1,2,3]', '[]') |
+--------------------------------+
|                              1 |
+--------------------------------+
1 row in set (0.00 sec)
[2 Feb 2023 10:06] MySQL Verification Team
Hello x j,

Thank you for the report and feedback.
This sounds like a doc issue than a code bug to me.

regards,
Umesh