Bug #79003 JSON_QUOTE only accepts string arguments

Submitted: 28 Oct 2015 16:05 Modified: 30 Oct 2015 6:09
Reporter: Roland Bouman Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: JSON Severity:S4 (Feature request)
Version:5.7 OS:Any
Assigned to: CPU Architecture:Any

[28 Oct 2015 16:05] Roland Bouman
Description:
json_quote only accepts string arguments. It would be much more convenient if it would automatically convert values other datatypes in the usual way to their string equivalent.

How to repeat:
mysql> select json_quote(0.1);
ERROR 3064 (HY000): Incorrect type for argument 1 in function json_quote.

Suggested fix:
Modify JSON_QUOTE to accept other value types than string types.
[28 Oct 2015 22:03] Roland Bouman
category JSON
[30 Oct 2015 6:09] MySQL Verification Team
Hello Roland,

Thank you for the feature request.

Thanks,
Umesh
[30 Oct 2015 9:53] Knut Anders Hatlen
Thanks for the feedback, Roland. This should be easy enough to change, if it's the right thing to do. Is there a particular use case you have in mind for this?

The reasoning behind requiring explicit casts of non-strings to a string type, was that JSON_QUOTE was believed to be most useful for strings. Since quoting numbers was believed to be a rare use case, we thought this minor inconvenience would be acceptable. The benefit is that an error is raised so that unintentional quoting of numbers is detected and can be corrected at an early stage.

If it turns out that quoting numbers is not such a rare use case after all, we should reconsider this decision.

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.