[MDEV-15561] json_extract returns NULL with numbers in scientific notation Created: 2018-03-14  Updated: 2020-08-25  Resolved: 2018-03-24

Status: Closed
Project: MariaDB Server
Component/s: JSON
Affects Version/s: 10.2.13, 10.2, 10.3
Fix Version/s: 10.3.6

Type: Bug Priority: Major
Reporter: Richard Stracke Assignee: Alexey Botchkov
Resolution: Fixed Votes: 1
Labels: None
Environment:

tested with MariaDB 10.2.13 on Debian 8


Sprint: 10.3.6-1

 Description   

json_extract returns NULL for a number in scientific notation.

MariaDB [(none)]> select json_extract('{"test":8.437e-5}','$.test'); 
+--------------------------------------------+
| json_extract('{"test":8.437e-5}','$.test') |
+--------------------------------------------+
| NULL                                       |
+--------------------------------------------+

with the following warning

MariaDB [(none)]> show warnings;
+---------+------+----------------------------------------------------------------------------------+
| Level   | Code | Message                                                                          |
+---------+------+----------------------------------------------------------------------------------+
| Warning | 4038 | Syntax error in JSON text in argument 1 to function 'json_extract' at position 8 |
+---------+------+----------------------------------------------------------------------------------+

json value works.

+------------------------------------------+
| json_value('{"test":8.437e-5}','$.test') |
+------------------------------------------+
| 8.437e-5                                 |
+------------------------------------------+
1 row in set (0.00 sec)

json_valid returns true for the given document

MariaDB [(none)]> select json_valid('{"test":8.437e-5}');
+---------------------------------+
| json_valid('{"test":8.437e-5}') |
+---------------------------------+
|                               1 |
+---------------------------------+



 Comments   
Comment by Elena Stepanova [ 2018-03-16 ]

MySQL works:

MySQL [test]> select json_extract('{"test":8.437e-5}','$.test');
+--------------------------------------------+
| json_extract('{"test":8.437e-5}','$.test') |
+--------------------------------------------+
| 0.00008437                                 |
+--------------------------------------------+
1 row in set (0.00 sec)

Comment by Alexey Botchkov [ 2018-03-24 ]

http://lists.askmonty.org/pipermail/commits/2018-March/012131.html

Comment by Tomas Lamr [ 2018-11-27 ]

Hi guys! Thank you for your hard work, it seems that json_extract is unable to extract 0 as scientific notation (i.e. 0E-10), described it MDEV-17850

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