[MDEV-13645] JSON_QUOTE() - return NULL on numbers Created: 2017-08-25  Updated: 2023-02-15

Status: Open
Project: MariaDB Server
Component/s: JSON
Affects Version/s: 10.2.8
Fix Version/s: 10.2

Type: Bug Priority: Minor
Reporter: Michal Hucik Assignee: Rucha Deodhar
Resolution: Unresolved Votes: 0
Labels: None
Environment:

Centos Linux 7.3



 Description   

I'm not sure if this is really a bug, but why JSON_QUOTE () returns NULL when the input parameter is not a string, but a number?

My opinion in that case, is that the return value must be the same as input number.

MariaDB [test]> SELECT JSON_QUOTE(90211);
+-------------------+
| JSON_QUOTE(90211) |
+-------------------+
| NULL              |
+-------------------+
1 row in set (0.00 sec)



 Comments   
Comment by Elena Stepanova [ 2017-08-25 ]

Thanks for the report.

At least there is a documentation problem. In MySQL 5.7 it also does not work:

5.7

MySQL [test]> SELECT JSON_QUOTE(90211);
ERROR 3064 (HY000): Incorrect type for argument 1 in function json_quote.

However, there JSON_QUOTE is clearly documented as a function with a string argument, so the failure is justified.

In MariaDB, JSON_QUOTE is documented as a function with json_value argument (whatever it means).

Also, even though we implemented implicit "NULL upon error" logic for JSON functions, there should be a warning if the argument is incorrect, so it's another example for MDEV-12311.

Comment by Weijun Huang [ 2023-02-15 ]

In MySQL 8.0, it also does not work.

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