dao: catch errors on Model creation in find
This commit is contained in:
parent
a6c5802940
commit
248aaf0541
|
@ -1982,7 +1982,7 @@ DataAccessObject.find = function find(query, options, cb) {
|
|||
try {
|
||||
obj = new Model(data, ctorOpts);
|
||||
} catch (err) {
|
||||
return cb(err);
|
||||
return callback(err);
|
||||
}
|
||||
|
||||
if (query && query.include) {
|
||||
|
|
|
@ -654,6 +654,15 @@ describe('basic-querying', function() {
|
|||
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();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in New Issue