From 248aaf0541677fc24a0e74bcd3b20592685b5580 Mon Sep 17 00:00:00 2001 From: Kevin Delisle Date: Thu, 16 Mar 2017 17:25:29 -0400 Subject: [PATCH] dao: catch errors on Model creation in find --- lib/dao.js | 2 +- test/basic-querying.test.js | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/dao.js b/lib/dao.js index 869e9c50..eb24daf3 100644 --- a/lib/dao.js +++ b/lib/dao.js @@ -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) { diff --git a/test/basic-querying.test.js b/test/basic-querying.test.js index be8133d8..300c3253 100644 --- a/test/basic-querying.test.js +++ b/test/basic-querying.test.js @@ -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(); + }); + }); }); });