Bug #80639 use json_extract/json_set cat not select or insert value
Submitted: 7 Mar 2016 10:22 Modified: 9 Mar 2016 12:04
Reporter: stevenss migao Email Updates:
Status: Not a Bug Impact on me:
None 
Category:MySQL Server: Data Types Severity:S4 (Feature request)
Version:5.7.10 OS:Red Hat (4.8.2-16)
Assigned to: CPU Architecture:Any
Tags: JSON JSON_EXTRACT JSON_SET

[7 Mar 2016 10:22] stevenss migao
Description:
I want use a UUID (which delete the sign '-') as a key, but when I query or update it, always report me an error, the init data is insert by java code. I'm not sure this problem is occured by UUID, but other sql is OK. I'm confused~~

How to repeat:
error sql:
select json_extract(info_detail, '$.contacts.1fc7e5c4e4174cf593baa1d7349a5037') from t_user_info where id =3000;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'version' at line 1

other sql:
select json_extract(info_detail, '$.idcards.idcardFront') from t_user_info  where id = 3000;
+--------------------------------------------------+
| json_extract(info_detail, '$.idcards.idcardFront') |
+--------------------------------------------------+
| {"serverId": "1", "sourceType": "camera"}        |
+--------------------------------------------------+
[7 Mar 2016 10:37] stevenss migao
God!!
I got it. Because the UUID I used is begin with a Number~! Is this a bug??? I'm not sure...
[9 Mar 2016 12:04] Knut Anders Hatlen
Thanks for the report. As you found out, the error is raised because the key name starts with a number. This is expected, and not a bug. See the description of the JSON path syntax here: https://dev.mysql.com/doc/refman/5.7/en/json-path-syntax.html

The key name must either be an ECMAScript identifier or a double-quoted string. ECMAScript identifiers cannot start with a number, so you need to use a double-quoted string for this key. The following should work:

select json_extract(info_detail, '$.contacts."1fc7e5c4e4174cf593baa1d7349a5037"') from t_user_info where id = 3000