Details
-
Bug
-
Status: Stalled (View Workflow)
-
Major
-
Resolution: Unresolved
-
10.2, 10.3, 10.4, 10.5, 10.6
-
None
Description
10.2 ba7d86a6 |
MariaDB [test]> select json_value('{"a":[1,2]}', '$.a[*]'); |
+-------------------------------------+ |
| json_value('{"a":[1,2]}', '$.a[*]') | |
+-------------------------------------+ |
| 1 |
|
+-------------------------------------+ |
1 row in set (0.000 sec) |
So, the provided path refers to two values, of which the function picks up one and returns it. It is a wrong result, the expected result is an error. The standard is very specific about it:
JSON_VALUE expects that the SQL/JSON path expression will return one SQL/JSON item; the ON EMPTY clause can be used to handle missing data (no SQL/JSON items) gracefully. More than one SQL/JSON item is an error.
MySQL returns NULL, which implies an error:
MySQL 8.0.23 |
MySQL [test]> select json_value('{"a":[1,2]}', '$.a[*]'); |
+-------------------------------------+ |
| json_value('{"a":[1,2]}', '$.a[*]') | |
+-------------------------------------+ |
| NULL | |
+-------------------------------------+ |
1 row in set (0.000 sec) |