Details
-
Task
-
Status: Closed (View Workflow)
-
Critical
-
Resolution: Fixed
Description
JSON Path allows to specify a negative array index, eg $[-1] returns the last element. This is not supported in MariaDB.
Because of this, I believe there is no way to retrieve the last element without knowing the array length, nor to insert (JSON_ARRAY_INSERT()) an element at the end of the array. If I'm correct, this is a major missing feature for those who use JSON functions.
MariaDB [test]> SELECT JSON_EXTRACT(JSON_ARRAY(1, 2, 3), '$[-1]'); |
+--------------------------------------------+ |
| JSON_EXTRACT(JSON_ARRAY(1, 2, 3), '$[-1]') | |
+--------------------------------------------+ |
| NULL | |
+--------------------------------------------+ |
1 row in set, 1 warning (0.000 sec) |
 |
Warning (Code 4042): Syntax error in JSON path in argument 2 to function 'json_extract' at position 3 |
UPDATE: The task includes adding the negative index and the new keyword "last"
Attachments
Issue Links
- causes
-
MDEV-28319 Assertion `cur_step->type & JSON_PATH_KEY' failed in json_find_path
- Closed
-
MDEV-29381 JSON paths containing dashes are reported as syntax errors in procedures
- Closed
-
MDEV-29586 JSON_VALUE and JSON_EXTRACT doesn't handle special characters
- Closed
- is part of
-
MDEV-28112 prepare 10.9.0 preview releases
- Closed
- relates to
-
MDEV-27972 Unexpected behavior with negative zero (-0) in JSON Path
- Closed
-
MDEV-28350 Test failing on buildbot with UBSAN
- Closed