diff --git a/package.json b/package.json index 11140fd5d2..ad742238bf 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,6 @@ "estraverse": "^4.2.0", "istanbul": "^0.4.5", "json-loader": "^0.5.7", - "mariasql": "^0.2.6", "mocha": "^3.5.3", "mock-fs": "^4.4.2", "mssql": "^4.1.0", @@ -101,7 +100,6 @@ "query", "postgresql", "mysql", - "mariadb", "sqlite3", "oracle", "mssql" @@ -117,7 +115,6 @@ "mssql": false, "mysql": false, "mysql2": false, - "mariasql": false, "pg": false, "pg-query-stream": false, "oracle": false, diff --git a/src/dialects/maria/index.js b/src/dialects/maria/index.js deleted file mode 100644 index 6f9cd9cdb6..0000000000 --- a/src/dialects/maria/index.js +++ /dev/null @@ -1,171 +0,0 @@ - -// MariaSQL Client -// ------- -import inherits from 'inherits'; -import Client_MySQL from '../mysql'; -import Promise from 'bluebird'; -import Transaction from './transaction'; - -import { assign, map } from 'lodash' - -function Client_MariaSQL(config) { - Client_MySQL.call(this, config) -} -inherits(Client_MariaSQL, Client_MySQL) - -assign(Client_MariaSQL.prototype, { - - dialect: 'mariadb', - - driverName: 'mariasql', - - transaction() { - return new Transaction(this, ...arguments) - }, - - _driver() { - return require('mariasql') - }, - - // Get a raw connection, called by the `pool` whenever a new - // connection needs to be added to the pool. - acquireRawConnection() { - return new Promise((resolver, rejecter) => { - const connection = new this.driver(); - connection.connect(assign({metadata: true}, this.connectionSettings)) - connection - .on('ready', function() { - resolver(connection); - }) - .on('error', err => { - connection.__knex__disposed = err - rejecter(err) - }); - }) - }, - - validateConnection(connection) { - if (connection.connected === true) { - return true - } - - return false - }, - - // Used to explicitly close a connection, called internally by the pool - // when a connection times out or the pool is shutdown. - destroyRawConnection(connection) { - connection.removeAllListeners() - let closed = Promise.resolve() - if (connection.connected || connection.connecting) { - closed = new Promise(resolve => { connection.once('close', resolve)}) - } - connection.end() - return closed - }, - - // Return the database for the MariaSQL client. - database() { - return this.connectionSettings.db; - }, - - // Grab a connection, run the query via the MariaSQL streaming interface, - // and pass that through to the stream we've sent back to the client. - _stream(connection, sql, stream) { - return new Promise(function(resolver, rejecter) { - connection.query(sql.sql, sql.bindings) - .on('result', function(res) { - res - .on('error', (err) => { - rejecter(err) - stream.emit('error', err) - }) - .on('end', function() { - resolver(res.info); - }) - .on('data', function (data) { - stream.write(handleRow(data, res.info.metadata)); - }) - }) - .on('error', rejecter); - }); - }, - - // Runs the query on the specified connection, providing the bindings - // and any other necessary prep work. - _query(connection, obj) { - const tz = this.connectionSettings.timezone || 'local'; - return new Promise((resolver, rejecter) => { - if (!obj.sql) return resolver() - const sql = this._formatQuery(obj.sql, obj.bindings, tz) - connection.query(sql, function (err, rows) { - if (err) { - return rejecter(err); - } - handleRows(rows, rows.info.metadata); - obj.response = [rows, rows.info]; - resolver(obj); - }) - }); - }, - - // Process the response as returned from the query. - processResponse(obj, runner) { - const { response } = obj; - const { method } = obj; - const rows = response[0]; - const data = response[1]; - if (obj.output) return obj.output.call(runner, rows/*, fields*/); - switch (method) { - case 'select': - case 'pluck': - case 'first': { - if (method === 'pluck') return map(rows, obj.pluck); - return method === 'first' ? rows[0] : rows; - } - case 'insert': - return [data.insertId]; - case 'del': - case 'update': - case 'counter': - return parseInt(data.affectedRows, 10); - default: - return response; - } - } - -}) - -function parseType(value, type) { - switch (type) { - case 'DATETIME': - case 'TIMESTAMP': - return new Date(value); - case 'INTEGER': - return parseInt(value, 10); - case 'FLOAT': - return parseFloat(value); - default: - return value; - } -} - -function handleRow(row, metadata) { - const keys = Object.keys(metadata); - for (let i = 0; i < keys.length; i++) { - const key = keys[i]; - const { type } = metadata[key]; - row[key] = parseType(row[key], type); - } - return row; -} - -function handleRows(rows, metadata) { - for (let i = 0; i < rows.length; i++) { - const row = rows[i]; - handleRow(row, metadata); - } - return rows; -} - -export default Client_MariaSQL diff --git a/src/dialects/maria/transaction.js b/src/dialects/maria/transaction.js deleted file mode 100644 index 338186a02a..0000000000 --- a/src/dialects/maria/transaction.js +++ /dev/null @@ -1,39 +0,0 @@ -import Debug from 'debug'; -import Transaction from '../../transaction'; -import {isUndefined} from 'lodash'; - -const debug = Debug('knex:tx'); - -export default class Transaction_Maria extends Transaction { - - query(conn, sql, status, value) { - const t = this - const q = this.trxClient.query(conn, sql) - .catch(err => err.code === 1305, () => { - this.trxClient.logger.warn( - 'Transaction was implicitly committed, do not mix transactions and ' + - 'DDL with MariaDB (#805)' - ); - }) - .catch(function(err) { - status = 2 - value = err - t._completed = true - debug('%s error running transaction query', t.txid) - }) - .tap(function() { - if (status === 1) t._resolver(value) - if (status === 2) { - if(isUndefined(value)) { - value = new Error(`Transaction rejected with non-error: ${value}`) - } - t._rejecter(value) - } - }) - if (status === 1 || status === 2) { - t._completed = true - } - return q; - } - -} diff --git a/src/index.js b/src/index.js index 859c5a5601..b796d76aad 100644 --- a/src/index.js +++ b/src/index.js @@ -9,8 +9,6 @@ import { assign } from 'lodash' // The client names we'll allow in the `{name: lib}` pairing. const aliases = { - 'mariadb' : 'maria', - 'mariasql' : 'maria', 'pg' : 'postgres', 'postgresql' : 'postgres', 'sqlite' : 'sqlite3' diff --git a/src/util/parse-connection.js b/src/util/parse-connection.js index d6ec093fb7..a5f277098d 100644 --- a/src/util/parse-connection.js +++ b/src/util/parse-connection.js @@ -5,9 +5,6 @@ import { parse as parsePG } from 'pg-connection-string' export default function parseConnectionString(str) { const parsed = url.parse(str) let { protocol } = parsed - if (protocol && protocol.indexOf('maria') === 0) { - protocol = 'maria' - } if (protocol === null) { return { client: 'sqlite3', @@ -34,11 +31,9 @@ function connectionObject(parsed) { if (db[0] === '/') { db = db.slice(1) } - if (parsed.protocol.indexOf('maria') === 0) { - connection.db = db - } else { - connection.database = db - } + + connection.database = db + if (parsed.hostname) { if (parsed.protocol.indexOf('mssql') === 0) { connection.server = parsed.hostname; diff --git a/test/index.js b/test/index.js index aa8a5145da..1e3f2b0889 100644 --- a/test/index.js +++ b/test/index.js @@ -22,7 +22,6 @@ describe('Query Building Tests', function() { require('./unit/query/builder') require('./unit/schema/mysql')('mysql') - require('./unit/schema/mysql')('maria') require('./unit/schema/mysql')('mysql2') require('./unit/schema/postgres') require('./unit/schema/redshift') diff --git a/test/integration/builder/additional.js b/test/integration/builder/additional.js index 091d6fdb93..7cdf744d29 100644 --- a/test/integration/builder/additional.js +++ b/test/integration/builder/additional.js @@ -250,7 +250,6 @@ module.exports = function(knex) { var tables = { mysql: 'SHOW TABLES', mysql2: 'SHOW TABLES', - mariadb: 'SHOW TABLES', postgresql: "SELECT table_name FROM information_schema.tables WHERE table_schema='public'", redshift: "SELECT table_name FROM information_schema.tables WHERE table_schema='public'", sqlite3: "SELECT name FROM sqlite_master WHERE type='table';", @@ -536,9 +535,6 @@ module.exports = function(knex) { 'mysql2': function() { return knex.raw('SELECT SLEEP(1)'); }, - mariadb: function() { - return knex.raw('SELECT SLEEP(1)'); - }, mssql: function() { return knex.raw('WAITFOR DELAY \'00:00:01\''); }, @@ -587,9 +583,6 @@ module.exports = function(knex) { 'mysql2': function() { return knex.raw('SELECT SLEEP(10)'); }, - mariadb: function() { - return knex.raw('SELECT SLEEP(10)'); - }, mssql: function() { return knex.raw('WAITFOR DELAY \'00:00:10\''); }, @@ -608,8 +601,8 @@ module.exports = function(knex) { return query.timeout(200, {cancel: true}); } - // Only mysql/mariadb query cancelling supported for now - if (!_.startsWith(dialect, "mysql") && !_.startsWith(dialect, "maria")) { + // Only mysql query cancelling supported for now + if (!_.startsWith(dialect, "mysql")) { expect(addTimeout).to.throw("Query cancelling not supported for this dialect"); return; } @@ -643,9 +636,9 @@ module.exports = function(knex) { it('.timeout(ms, {cancel: true}) should throw error if cancellation cannot acquire connection', function() { - // Only mysql/mariadb query cancelling supported for now + // Only mysql query cancelling supported for now var dialect = knex.client.config.dialect; - if (!_.startsWith(dialect, "mysql") && !_.startsWith(dialect, "maria")) { + if (!_.startsWith(dialect, "mysql")) { return; } diff --git a/test/integration/migrate/index.js b/test/integration/migrate/index.js index 13185ffd4a..13ede5fd4d 100644 --- a/test/integration/migrate/index.js +++ b/test/integration/migrate/index.js @@ -330,7 +330,7 @@ module.exports = function(knex) { // MySQL / Oracle commit transactions implicit for most common // migration statements (e.g. CREATE TABLE, ALTER TABLE, DROP TABLE), // so we need to check for dialect - if (knex.client.dialect === 'mysql' || knex.client.dialect === 'mariadb' || knex.client.dialect === 'oracle') { + if (knex.client.dialect === 'mysql' || knex.client.dialect === 'oracle') { expect(exists).to.equal(true); } else { expect(exists).to.equal(false); diff --git a/test/integration/schema/index.js b/test/integration/schema/index.js index d2e2ebd972..6686f49258 100644 --- a/test/integration/schema/index.js +++ b/test/integration/schema/index.js @@ -124,8 +124,8 @@ module.exports = function(knex) { }); }); - describe('increments types - mysql/maria', function() { - if(!knex || !knex.client || (!(/mysql/i.test(knex.client.dialect)) && !(/maria/i.test(knex.client.dialect)))) { + describe('increments types - mysql', function() { + if(!knex || !knex.client || (!(/mysql/i.test(knex.client.dialect)))) { return Promise.resolve(); } @@ -695,7 +695,7 @@ module.exports = function(knex) { describe('mysql only', function() { if (!knex || !knex.client || - (!(/mysql/i.test(knex.client.dialect)) && !(/maria/i.test(knex.client.dialect))) + (!(/mysql/i.test(knex.client.dialect))) ) { return Promise.resolve(); } diff --git a/test/knexfile.js b/test/knexfile.js index dfd761e94d..bca618b862 100644 --- a/test/knexfile.js +++ b/test/knexfile.js @@ -7,7 +7,7 @@ var _ = require('lodash'); var Promise = require('bluebird'); // excluding redshift, oracle, and mssql dialects from default integrations test -var testIntegrationDialects = (process.env.DB || "maria mysql mysql2 postgres sqlite3").match(/\w+/g); +var testIntegrationDialects = (process.env.DB || "mysql mysql2 postgres sqlite3").match(/\w+/g); var pool = { afterCreate: function(connection, callback) { @@ -24,17 +24,6 @@ var mysqlPool = _.extend({}, pool, { } }); -var mariaPool = _.extend({}, pool, { - afterCreate: function(connection, callback) { - var query = connection.query("SET sql_mode='TRADITIONAL';", []) - query.on('result', function(result) { - result.on('end', function() { - callback(null, connection) - }) - }) - } -}); - var migrations = { directory: 'test/integration/migrate/migration' }; @@ -44,20 +33,6 @@ var seeds = { }; var testConfigs = { - - maria: { - dialect: 'maria', - connection: testConfig.maria || { - db: "knex_test", - user: "root", - charset: 'utf8', - host: '127.0.0.1' - }, - pool: mariaPool, - migrations: migrations, - seeds: seeds - }, - mysql: { dialect: 'mysql', connection: testConfig.mysql || { diff --git a/test/tape/parse-connection.js b/test/tape/parse-connection.js index a1f0922093..b2c31fc04f 100644 --- a/test/tape/parse-connection.js +++ b/test/tape/parse-connection.js @@ -30,22 +30,6 @@ test('parses standard connections without password', function(t) { }) }) -test('parses maria connections, aliasing database to db', function(t) { - t.plan(3) - var maria = { - client: 'maria', - connection: { - user: 'username', - password: 'pass', - host: 'path.to.some-url', - port: '6000', - db: 'testdb' - } - } - t.deepEqual(parseConnection('maria://username:pass@path.to.some-url:6000/testdb'), maria) - t.deepEqual(parseConnection('mariasql://username:pass@path.to.some-url:6000/testdb'), maria) - t.deepEqual(parseConnection('mariadb://username:pass@path.to.some-url:6000/testdb'), maria) -}) test('parses mssql connections, aliasing host to server', function(t) { t.plan(1) diff --git a/test/unit/schema/mysql.js b/test/unit/schema/mysql.js index 005068ddeb..26389da476 100644 --- a/test/unit/schema/mysql.js +++ b/test/unit/schema/mysql.js @@ -4,7 +4,6 @@ var sinon = require('sinon'); var MySQL_Client = require('../../../lib/dialects/mysql'); -var Maria_Client = require('../../../lib/dialects/maria'); var MySQL2_Client = require('../../../lib/dialects/mysql2'); module.exports = function(dialect) { @@ -15,7 +14,6 @@ describe(dialect + " SchemaBuilder", function() { switch(dialect) { case 'mysql': client = new MySQL_Client(); break; case 'mysql2': client = new MySQL2_Client(); break; - case 'maria': client = new Maria_Client(); break; } var tableSql;