knex/lib/dialects/mysql2/index.js

36 lines
814 B
JavaScript
Raw Normal View History

2015-05-09 13:58:18 -04:00
// MySQL2 Client
// -------
const { inherits } = require('util');
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) {
Client_MySQL.call(this, config);
2015-05-09 13:58:18 -04:00
}
inherits(Client_MySQL2, Client_MySQL);
2015-05-09 13:58:18 -04: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() {
return new Transaction(this, ...arguments);
2016-09-12 18:45:35 -04:00
},
2015-05-09 13:58:18 -04:00
_driver() {
return require('mysql2');
2015-07-02 18:28:34 -04:00
},
2015-05-09 13:58:18 -04:00
validateConnection(connection) {
if (connection._fatalError) {
return false;
}
return true;
},
});
2015-05-09 13:58:18 -04:00
module.exports = Client_MySQL2;