Bug #92749 JSON arrow operator not wotking with variables and functions

Submitted: 11 Oct 2018 11:28 Modified: 11 Oct 2018 13:37
Reporter: Andrej Thomsen Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: JSON Severity:S3 (Non-critical)
Version:8, 8.0.12 OS:Any
Assigned to: CPU Architecture:Any
Tags: arrow, EXTRACT, json, operator, variable

[11 Oct 2018 11:28] Andrej Thomsen
Description:
The arrow operator doesn't work with functions, strings or variables.
The documentation states the first parameter must be a column but usually such functions are working with variables and function responses as well.

How to repeat:
CREATE FUNCTION passedJson() returns JSON DETERMINISTIC NO SQL return @passedJson;

SET @passedJson= '{"DateRange":{"Start":"2018-11-01","End":"2018-09-30"}}';

SELECT JSON_EXTRACT(@passedJson, "$.DateRange.Start") AS `works`;
SELECT JSON_EXTRACT(passedJson(), "$.DateRange.Start") AS `works`;
SELECT @passedJson->"$.DateRange.Start" AS `doesnt`;
SELECT passedJson()->"$.DateRange.Start" AS `doesnt`;
SELECT  JSON_EXTRACT('{"DateRange":{"Start":"2018-11-01","End":"2018-09-30"}}', "$.DateRange.Start") AS `doesnt`;

Suggested fix:
Enable arrow operators (col->path) and unquoting extraction operators (col->>path) to be used with functions, strings and variables.
[11 Oct 2018 13:37] MySQL Verification Team
Hello Andrej,

Thank you for the report!

regards,
Umesh

Portions of this website are copyright © 2001, 2002 The PHP Group

Page generated in 0.052 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.