[MDEV-15905] select json_value('{"b":true}','$.b')=1 --> false with "Truncated incorrect DOUBLE value: 'true'" Created: 2018-04-17  Updated: 2020-08-25  Resolved: 2018-06-17

Status: Closed
Project: MariaDB Server
Component/s: JSON
Affects Version/s: 10.2
Fix Version/s: 10.2.16

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

Issue Links:
Relates
relates to MDEV-22976 CAST(JSON_EXTRACT() AS DECIMAL) does ... Closed

 Description   

Hio,

MariaDB [(none)]> select json_extract('{"b":true}','$.b')=1;
+------------------------------------+
| json_extract('{"b":true}','$.b')=1 |
+------------------------------------+
|                                  1 |
+------------------------------------+
1 row in set (0.00 sec)
 
MariaDB [test]> select json_value('{"b":true}','$.b')=1;
+----------------------------------+
| json_value('{"b":true}','$.b')=1 |
+----------------------------------+
|                                0 |
+----------------------------------+
1 row in set, 1 warning (0.00 sec)
 
MariaDB [(none)]> show warnings;
+---------+------+------------------------------------------+
| Level   | Code | Message                                  |
+---------+------+------------------------------------------+
| Warning | 1292 | Truncated incorrect DOUBLE value: 'true' |
+---------+------+------------------------------------------+
1 row in set (0.00 sec)

But this works

MariaDB [(none)]>  select json_value('{"b":"true"}','$.b')='true';
+-----------------------------------------+
| json_value('{"b":"true"}','$.b')='true' |
+-----------------------------------------+
|                                       1 |
+-----------------------------------------+
1 row in set (0.00 sec)
 
MariaDB [(none)]> select json_value('{"b":true}','$.b')='true';
+---------------------------------------+
| json_value('{"b":true}','$.b')='true' |
+---------------------------------------+
|                                     1 |
+---------------------------------------+
1 row in set (0.00 sec)



 Comments   
Comment by Elena Stepanova [ 2018-05-30 ]

I'd say that if there is a problem, it's that json_extract does not produce a warning, while json_value does; but I'll leave it to holyfoot to determine what is bug here and what's not.

Comment by Alexey Botchkov [ 2018-06-17 ]

http://lists.askmonty.org/pipermail/commits/2018-June/012624.html

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