From 5a7a30acdd6129e1031d54d5e6148e4b3a02302f Mon Sep 17 00:00:00 2001 From: Alex Yaroshevich Date: Mon, 4 Feb 2013 06:03:46 +0400 Subject: [PATCH] Fixup mistyped regexp MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit There is no «Unknown database 'dbname'» but «ER_BAD_DB_ERROR: Unknown database 'dbname'» --- lib/mysql.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/mysql.js b/lib/mysql.js index 90eb712..f8a7caa 100644 --- a/lib/mysql.js +++ b/lib/mysql.js @@ -26,7 +26,7 @@ exports.initialize = function initializeSchema(schema, callback) { // schema.client.query('SET TIME_ZONE = "+04:00"', callback); schema.client.query('USE `' + s.database + '`', function (err) { - if (err && err.message.match(/^unknown database/i)) { + if (err && err.message.match(/(^|: )unknown database/i)) { var dbName = s.database; schema.client.query('CREATE DATABASE ' + dbName, function (error) { if (!error) { @@ -66,8 +66,8 @@ MySQL.prototype.query = function (sql, callback) { var log = this.log; if (typeof callback !== 'function') throw new Error('callback should be a function'); this.client.query(sql, function (err, data) { - if (err && err.message.match(/^unknown database/i)) { - var dbName = err.message.match(/^unknown database '(.*?)'/i)[1]; + if (err && err.message.match(/(^|: )unknown database/i)) { + var dbName = err.message.match(/(^|: )unknown database '(.*?)'/i)[1]; client.query('CREATE DATABASE ' + dbName, function (error) { if (!error) { client.query(sql, callback);