Merge branch 'TorchlightSoftware-discover-hang'
This commit is contained in:
commit
e86ecab507
|
@ -1237,7 +1237,7 @@ DataSource.prototype.discoverSchema = function(modelName, options, cb) {
|
||||||
cb = cb || utils.createPromiseCallback();
|
cb = cb || utils.createPromiseCallback();
|
||||||
|
|
||||||
this.discoverSchemas(modelName, options, function(err, schemas) {
|
this.discoverSchemas(modelName, options, function(err, schemas) {
|
||||||
if (err) {
|
if (err || !schemas) {
|
||||||
cb && cb(err, schemas);
|
cb && cb(err, schemas);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1316,7 +1316,7 @@ DataSource.prototype.discoverSchemas = function(modelName, options, cb) {
|
||||||
|
|
||||||
var columns = results[0];
|
var columns = results[0];
|
||||||
if (!columns || columns.length === 0) {
|
if (!columns || columns.length === 0) {
|
||||||
cb();
|
cb(new Error('Table \'' + modelName + '\' does not exist.'));
|
||||||
return cb.promise;
|
return cb.promise;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -625,3 +625,27 @@ describe('Mock connector', 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();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
Loading…
Reference in New Issue