dao: catch errors on Model creation in find

This commit is contained in:
Kevin Delisle 2017-03-16 17:25:29 -04:00
parent a6c5802940
commit 248aaf0541
2 changed files with 10 additions and 1 deletions

View File

@ -1982,7 +1982,7 @@ DataAccessObject.find = function find(query, options, cb) {
try { try {
obj = new Model(data, ctorOpts); obj = new Model(data, ctorOpts);
} catch (err) { } catch (err) {
return cb(err); return callback(err);
} }
if (query && query.include) { if (query && query.include) {

View File

@ -654,6 +654,15 @@ describe('basic-querying', function() {
done(); done();
}); });
}); });
it('should fail when querying with an invalid value for a type',
function(done) {
User.find({where: {birthday: 'notadate'}}, function(err, users) {
should.exist(err);
err.message.should.equal('Invalid date: notadate');
done();
});
});
}); });
}); });