Bug #103361 JSON_VALUE() does not accept an expression in path parameter
Submitted: 19 Apr 6:00 Modified: 19 Apr 6:19
Reporter: Владислав Сокол Email Updates:
Status: Verified Impact on me:
Category:MySQL Server: JSON Severity:S3 (Non-critical)
Version:8.0.23 OS:Any
Assigned to: CPU Architecture:Any

[19 Apr 6:00] Владислав Сокол
JSON_VALUE() accepts path parameter when string literal provided but fails if an expression is provided.

How to repeat:
CREATE TABLE test (`order` JSON)
SELECT '{"id":1,"price":123}' `order`;

SELECT JSON_VALUE(`order`, '$.price') price
FROM test;

-- output: price = 123

SELECT JSON_VALUE(`order`, LOWER('$.price')) price
FROM test

-- output: 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 'LOWER('$.price'))
FROM test' at line 1

-- fiddle: https://dbfiddle.uk/?rdbms=mysql_8.0&fiddle=762a9885fa071f6f5c0d5d0583374a15
[19 Apr 6:19] MySQL Verification Team
Hello Владислав Сокол,

Thank you for the report and feedback.

[13 May 23:05] Justin Levene
Can confirm in 8.0.23 I tried

json_value(my_json, CONCAT("$[",y,"].QTY") )

The above does not work