| 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: | |
| 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 13:37]
   MySQL Verification Team        
  Hello Andrej, Thank you for the report! regards, Umesh


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.