Bug #103692 Can't use -> or ->> with a user defined variable
Submitted: 14 May 2021 0:33 Modified: 14 May 2021 6:34
Reporter: Justin Levene Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: JSON Severity:S4 (Feature request)
Version:8.0.23, 8.0.25 OS:Any
Assigned to: CPU Architecture:Any

[14 May 2021 0:33] Justin Levene
Description:
Using -> or ->> wwith a user defined @ variable isn't allowed.

Also I reported in another bug report, the path can't be a variable or a concat() function. etc.

How to repeat:
set @js = '{"a":"99", "b":"2"}';
set @js = json_object("a",99, "b",2);

select @js->>"$.a";

Using either set won't work, and as this is an alias for json_extract, the following works:

select json_extract(@js, "$.a");

Suggested fix:
To work like json_extract as documented
[14 May 2021 6:34] MySQL Verification Team
Hello Justin Levene,

Thank you for the report and feedback.

regards,
Umesh
[14 May 2021 12:05] Knut Anders Hatlen
It looks like this was an intentional limitation of the original implementation of this syntax.

Both WL#8607 (the -> operator) and WL#9124 (the ->> operator) say under "High Level Architecture":

> f1       is a column identifier, general expressions aren't supported

Since it works as designed, I've recategorized the report from bug to feature request.