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.