Merge branch 'release/1.4.7' into production
This commit is contained in:
commit
dde39eefb1
13
lib/mysql.js
13
lib/mysql.js
|
@ -650,11 +650,15 @@ MySQL.prototype.autoupdate = function (models, cb) {
|
|||
|
||||
models = models || Object.keys(this._models);
|
||||
|
||||
async.each(models, function (model, done) {
|
||||
if (model in self._models) {
|
||||
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) {
|
||||
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 {
|
||||
|
@ -662,7 +666,6 @@ MySQL.prototype.autoupdate = function (models, cb) {
|
|||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
}, cb);
|
||||
|
||||
};
|
||||
|
|
|
@ -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",
|
||||
|
|
|
@ -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();
|
||||
|
|
Loading…
Reference in New Issue