2015-05-09 13:58:18 -04:00
|
|
|
// MySQL2 Client
|
|
|
|
// -------
|
2020-10-05 23:59:12 +03:00
|
|
|
const { inherits } = require('util');
|
2019-06-04 00:37:17 +02:00
|
|
|
const Client_MySQL = require('../mysql');
|
|
|
|
const Transaction = require('./transaction');
|
2015-05-09 13:58:18 -04:00
|
|
|
|
|
|
|
// Always initialize with the "QueryBuilder" and "QueryCompiler"
|
|
|
|
// objects, which extend the base 'lib/query/builder' and
|
|
|
|
// 'lib/query/compiler', respectively.
|
|
|
|
function Client_MySQL2(config) {
|
2018-07-09 08:10:34 -04:00
|
|
|
Client_MySQL.call(this, config);
|
2015-05-09 13:58:18 -04:00
|
|
|
}
|
2018-07-09 08:10:34 -04:00
|
|
|
inherits(Client_MySQL2, Client_MySQL);
|
2015-05-09 13:58:18 -04:00
|
|
|
|
2019-07-10 22:38:20 +02:00
|
|
|
Object.assign(Client_MySQL2.prototype, {
|
2015-05-09 13:58:18 -04:00
|
|
|
// The "dialect", for reference elsewhere.
|
|
|
|
driverName: 'mysql2',
|
|
|
|
|
2016-09-12 18:45:35 -04:00
|
|
|
transaction() {
|
2018-07-09 08:10:34 -04:00
|
|
|
return new Transaction(this, ...arguments);
|
2016-09-12 18:45:35 -04:00
|
|
|
},
|
2015-05-09 13:58:18 -04:00
|
|
|
|
2016-05-17 01:01:34 +10:00
|
|
|
_driver() {
|
2018-07-09 08:10:34 -04:00
|
|
|
return require('mysql2');
|
2015-07-02 18:28:34 -04:00
|
|
|
},
|
2015-05-09 13:58:18 -04:00
|
|
|
|
2017-09-06 14:51:29 -05:00
|
|
|
validateConnection(connection) {
|
2018-02-07 11:17:17 +02:00
|
|
|
if (connection._fatalError) {
|
2018-07-09 08:10:34 -04:00
|
|
|
return false;
|
2017-09-06 14:51:29 -05:00
|
|
|
}
|
2018-07-09 08:10:34 -04:00
|
|
|
return true;
|
|
|
|
},
|
|
|
|
});
|
2015-05-09 13:58:18 -04:00
|
|
|
|
2019-06-04 00:37:17 +02:00
|
|
|
module.exports = Client_MySQL2;
|