Merge branch 'release/1.4.7' into production

This commit is contained in:
Raymond Feng 2014-09-11 12:24:16 -07:00
commit dde39eefb1
3 changed files with 29 additions and 14 deletions

View File

@ -650,11 +650,15 @@ MySQL.prototype.autoupdate = function (models, cb) {
models = models || Object.keys(this._models); models = models || Object.keys(this._models);
async.each(models, function (model, done) { async.each(models, function(model, done) {
if (model in self._models) { if (!(model in self._models)) {
return process.nextTick(function() {
done(new Error('Model not found: ' + model));
});
}
var table = self.tableEscaped(model); var table = self.tableEscaped(model);
self.query('SHOW FIELDS FROM ' + table, function (err, fields) { self.query('SHOW FIELDS FROM ' + table, function(err, fields) {
self.query('SHOW INDEXES FROM ' + table, function (err, indexes) { self.query('SHOW INDEXES FROM ' + table, function(err, indexes) {
if (!err && fields && fields.length) { if (!err && fields && fields.length) {
self.alterTable(model, fields, indexes, done); self.alterTable(model, fields, indexes, done);
} else { } else {
@ -662,7 +666,6 @@ MySQL.prototype.autoupdate = function (models, cb) {
} }
}); });
}); });
}
}, cb); }, cb);
}; };

View File

@ -1,6 +1,6 @@
{ {
"name": "loopback-connector-mysql", "name": "loopback-connector-mysql",
"version": "1.4.6", "version": "1.4.7",
"description": "MySQL connector for loopback-datasource-juggler", "description": "MySQL connector for loopback-datasource-juggler",
"main": "index.js", "main": "index.js",
"scripts": { "scripts": {
@ -8,9 +8,9 @@
}, },
"dependencies": { "dependencies": {
"loopback-connector": "1.x", "loopback-connector": "1.x",
"mysql": "~2.3.2", "mysql": "~2.5.0",
"async": "~0.9.0", "async": "~0.9.0",
"debug": "~1.0.2" "debug": "~2.0.0"
}, },
"devDependencies": { "devDependencies": {
"loopback-datasource-juggler": "1.x.x", "loopback-datasource-juggler": "1.x.x",

View File

@ -304,6 +304,18 @@ describe('migrations', function () {
}); });
}); });
it('should report errors for automigrate', function() {
db.automigrate('XYZ', function(err) {
assert(err);
});
});
it('should report errors for autoupdate', function() {
db.autoupdate('XYZ', function(err) {
assert(err);
});
});
it('should disconnect when done', function (done) { it('should disconnect when done', function (done) {
db.disconnect(); db.disconnect();
done(); done();