From e00b0ba8cf78e862c4467bc0cd0660cc34003184 Mon Sep 17 00:00:00 2001 From: Geoffroy Lesage Date: Tue, 23 Dec 2014 04:06:24 -0600 Subject: [PATCH 1/2] Fixed isActual implemenation --- lib/mysql.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/mysql.js b/lib/mysql.js index 3390a56..4dde58e 100644 --- a/lib/mysql.js +++ b/lib/mysql.js @@ -691,10 +691,10 @@ MySQL.prototype.createTable = function (model, cb) { * @param {String[]} [models] A model name or an array of model names. If not present, apply to all models * @param {Function} [cb] The callback function */ -MySQL.prototype.isActual = function(cb) { +MySQL.prototype.isActual = function(models, cb) { var self = this; var ok = false; - async.each(Object.keys(this._models), function(model, done) { + async.each(Object.keys(models), function(model, done) { var table = self.tableEscaped(model); self.query('SHOW FIELDS FROM ' + table, function(err, fields) { self.query('SHOW INDEXES FROM ' + table, function(err, indexes) { From 9d3ab6fc42b8d43f7c01a229279666f95aa4b3b1 Mon Sep 17 00:00:00 2001 From: Geoffroy Lesage Date: Thu, 8 Jan 2015 10:29:55 -0600 Subject: [PATCH 2/2] Fixed isActual syntax to accept optional model arg --- lib/mysql.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/lib/mysql.js b/lib/mysql.js index 4dde58e..a9c32fe 100644 --- a/lib/mysql.js +++ b/lib/mysql.js @@ -693,7 +693,18 @@ MySQL.prototype.createTable = function (model, cb) { */ MySQL.prototype.isActual = function(models, cb) { var self = this; - var ok = false; + + if ((!cb) && ('function' === typeof models)) { + cb = models; + models = undefined; + } + // First argument is a model name + if ('string' === typeof models) { + models = [models]; + } + + models = models || Object.keys(this._models); + async.each(Object.keys(models), function(model, done) { var table = self.tableEscaped(model); self.query('SHOW FIELDS FROM ' + table, function(err, fields) {