discoverSchemas returns an error when modelName is not found,

discoverSchema forwards that error and does not hang when no columns,
no errors are returned
This commit is contained in:
bitmage 2016-01-22 10:41:06 -07:00
parent 2cdc4ddcbf
commit b556d96148
2 changed files with 26 additions and 2 deletions

View File

@ -1225,7 +1225,7 @@ DataSource.prototype.discoverSchema = function (modelName, options, cb) {
cb = cb || utils.createPromiseCallback();
this.discoverSchemas(modelName, options, function (err, schemas) {
if (err) {
if (err || !schemas) {
cb && cb(err, schemas);
return;
}
@ -1305,7 +1305,7 @@ DataSource.prototype.discoverSchemas = function (modelName, options, cb) {
var columns = results[0];
if (!columns || columns.length === 0) {
cb();
cb(new Error('Table \''+modelName+'\' does not exist.'));
return cb.promise;
}

View File

@ -602,3 +602,27 @@ describe('discoverExportedForeignKeys', function(){
});
});
});
describe('Default memory connector', function() {
var ds, nonExistantError = 'Table \'NONEXISTENT\' does not exist.';
before(function() {
ds = new DataSource({connector: 'memory'});
});
it('discoverSchema should return an error when table does not exist', function(done) {
ds.discoverSchema('NONEXISTENT', {}, function(err, schemas) {
should.exist(err);
err.message.should.eql(nonExistantError);
done();
});
});
it('discoverSchemas should return an error when table does not exist', function(done) {
ds.discoverSchemas('NONEXISTENT', {}, function(err, schemas) {
should.exist(err);
err.message.should.eql(nonExistantError);
done();
});
});
});