Closed scolestock closed 7 years ago
This will be added with the work being done in the mysql-wrapper branch. I'm working on rewriting the tests at the moment to get decent coverage.
@lukeb-uk Are there any updates on this issue?
If you set returnArgumentsArray
to true in the connection options (https://github.com/lukeb-uk/node-promise-mysql#connectionoptions-object) you will get an array back where the last argument is the return value from the query function call. You can do .sql
on that to get the sql.
Untested code, but it should give you an idea:
let connection;
mysql.createConnection({
user: 'root',
password: 'password',
database: 'employees',
returnArgumentsArray: true
}).then((conn) => {
connection = conn;
return connection.query('select * from employees limit 0, 10');
}).then(([data, fields, query]) => {
console.log(`The SQL for the query was: ${query.sql}\n`);
connection.end();
});
I'm curious whether there is a way to view the generated sql query, as the underlying mysql library provides for? thanks much !