Bug #99238 JSON Path implement negative offset

Submitted: 13 Apr 2020 10:04 Modified: 14 Apr 2020 12:26
Reporter: Federico Razzoli Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: JSON Severity:S4 (Feature request)
Version:8.0 OS:Any
Assigned to: CPU Architecture:Any

[13 Apr 2020 10:04] Federico Razzoli
Description:
JSON Path allows to extract the last element from an array by specifying a negative index:

$[-1]

It would be very handy to have this in MySQL.

How to repeat:
mysql> SELECT JSON_EXTRACT(JSON_ARRAY(1, 2, 3), '$[0]');
+-------------------------------------------+
| JSON_EXTRACT(JSON_ARRAY(1, 2, 3), '$[0]') |
+-------------------------------------------+
| 1                                         |
+-------------------------------------------+
1 row in set (0.00 sec)

mysql> SELECT JSON_EXTRACT(JSON_ARRAY(1, 2, 3), '$[-1]');
ERROR 3143 (42000): Invalid JSON path expression. The error is around character position 2.
[13 Apr 2020 10:05] Federico Razzoli
Setting to "feature request"
[14 Apr 2020 12:26] MySQL Verification Team
Hello Federico,

Thank you for the feature request!

regards,
Umesh

Portions of this website are copyright © 2001, 2002 The PHP Group

Page generated in 0.051 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.