Bug #81052 MODULE MYSQLX IS NOT AVAILABLE WHEN EXECUTING JAVASCRIPT QUERIES USING MYSQLX
Submitted: 12 Apr 2016 16:15 Modified: 14 Jun 2016 22:59
Reporter: Luis Penunuri Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Visual Studio Integration Severity:S2 (Serious)
Version:2.0.2 OS:Any
Assigned to: Luis Penunuri CPU Architecture:Any

[12 Apr 2016 16:15] Luis Penunuri
Description:
When executing javascript queries that involves the use of the "mysqlx" module, like:

    var mysqlx = require('mysqlx').mysqlx;
    ...
    table.update().set('first_name', mysqlx.expr('20+5')).where('last_name = :param1').bind('param1', 'GUINESS').execute();

The query is not executed properly, because the module "mysqlx" for javascript cannot be imported.

How to repeat:
1.- In server explorer, create a new connection to a MySQL Server supporting xShell (>= 5.7.12)
2.- With the connection created, right click on it and select "New MySQL Script -> Javascript"
3.- In the query window, type the following command:
    
    var mysqlx = require('mysqlx').mysqlx;
    var session = mysqlx.getSession('root:@localhost:33570');
    var table = session.sakila.getTable('actor');
    table.update().set('first_name', mysqlx.expr('20+5')).where('last_name = :param1').bind('param1', 'GUINESS').execute();
    table.select().execute();

* Current result:
The records with "last_name" = "GUINESS" are not updated setting the field "first_name" = "25", because an internal error in the xShell wrapper is thrown due the "mysqlx" javascript module cannot be imported.

* Expected result:
The field "first_name" should be updated to "25", for all the records with "last_name" = "GUINESS"

Note: The queries shown above works for a connection made using the "Sakila" schema, having data with "last_name" = "GUINESS". In order to validate the query was executed properly, you could execute the following query in Workbench:

    SELECT * FROM sakila.actor where last_name = 'GUINESS';

Suggested fix:
Validate the "modules" folder is installed in the correct folder so the xShell core can find the "mysqlx.js" module.
Currently, this folder is installed in a wrong path.
[14 Jun 2016 22:59] Philip Olson
Posted by developer:
 
Fixed as of the upcoming MySQL for Visual Studio 2.0.3 release, and here's the changelog entry:

The "mysqlx" module was not imported properly to execute JavaScript
queries.

Thank you for the bug report.