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

View File

@ -1,6 +1,6 @@
{
"name": "loopback-connector-mysql",
"version": "1.4.6",
"version": "1.4.7",
"description": "MySQL connector for loopback-datasource-juggler",
"main": "index.js",
"scripts": {
@ -8,9 +8,9 @@
},
"dependencies": {
"loopback-connector": "1.x",
"mysql": "~2.3.2",
"mysql": "~2.5.0",
"async": "~0.9.0",
"debug": "~1.0.2"
"debug": "~2.0.0"
},
"devDependencies": {
"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) {
db.disconnect();
done();