Fixup mistyped regexp

There is no «Unknown database 'dbname'» but «ER_BAD_DB_ERROR: Unknown database 'dbname'»
This commit is contained in:
Alex Yaroshevich 2013-02-04 06:03:46 +04:00
parent 035a8e8bac
commit 5a7a30acdd
1 changed files with 3 additions and 3 deletions

View File

@ -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);