2014-09-01 17:18:45 +02:00
|
|
|
'use strict';
|
|
|
|
|
2014-06-04 04:10:27 -04:00
|
|
|
// MariaSQL Client
|
2014-06-03 23:27:37 -04:00
|
|
|
// -------
|
2015-04-19 16:31:52 -04:00
|
|
|
var inherits = require('inherits')
|
|
|
|
var assign = require('lodash/object/assign')
|
|
|
|
var Client_MySQL = require('../mysql')
|
|
|
|
var Promise = require('../../promise')
|
2014-06-03 23:27:37 -04:00
|
|
|
|
|
|
|
var Mariasql;
|
|
|
|
|
2015-04-19 16:31:52 -04:00
|
|
|
function Client_MariaSQL(config) {
|
|
|
|
Client_MySQL.call(this, config);
|
2014-06-03 23:27:37 -04:00
|
|
|
}
|
|
|
|
inherits(Client_MariaSQL, Client_MySQL);
|
|
|
|
|
|
|
|
Client_MariaSQL.prototype.dialect = 'mariasql';
|
|
|
|
|
2015-04-19 16:31:52 -04:00
|
|
|
Client_MariaSQL.prototype.driverName = 'mariasql'
|
2014-06-03 23:27:37 -04:00
|
|
|
|
|
|
|
// Get a raw connection, called by the `pool` whenever a new
|
|
|
|
// connection needs to be added to the pool.
|
|
|
|
Client_MariaSQL.prototype.acquireRawConnection = function() {
|
|
|
|
var connection = new Mariasql();
|
2015-04-19 16:31:52 -04:00
|
|
|
connection.connect(assign({metadata: true}, this.connectionSettings));
|
2014-06-03 23:27:37 -04:00
|
|
|
return new Promise(function(resolver, rejecter) {
|
2015-04-19 16:31:52 -04:00
|
|
|
connection
|
|
|
|
.on('connect', function() {
|
|
|
|
connection.removeAllListeners('end');
|
|
|
|
connection.removeAllListeners('error');
|
|
|
|
resolver(connection);
|
|
|
|
})
|
|
|
|
.on('error', rejecter);
|
|
|
|
})
|
|
|
|
}
|
2014-06-03 23:27:37 -04:00
|
|
|
|
2014-06-04 04:10:27 -04:00
|
|
|
// Return the database for the MariaSQL client.
|
2014-06-03 23:27:37 -04:00
|
|
|
Client_MariaSQL.prototype.database = function() {
|
|
|
|
return this.connectionSettings.db;
|
2015-04-19 16:31:52 -04:00
|
|
|
}
|
2014-06-03 23:27:37 -04:00
|
|
|
|
2015-04-19 16:31:52 -04:00
|
|
|
module.exports = Client_MariaSQL
|