From c26b857a87b3431e5e9fe43a697ee67bb2566fb4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wilson=20J=C3=BAnior?= Date: Tue, 17 Nov 2015 17:02:43 -0200 Subject: [PATCH] UpdateAttributes: Raises an error if database fails MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Wilson JĂșnior --- lib/dao.js | 3 +++ test/manipulation.test.js | 12 ++++++++++++ 2 files changed, 15 insertions(+) diff --git a/lib/dao.js b/lib/dao.js index 3bf3214c..add16184 100644 --- a/lib/dao.js +++ b/lib/dao.js @@ -2449,6 +2449,9 @@ DataAccessObject.prototype.updateAttributes = function updateAttributes(data, op context.data = typedData; function updateAttributesCallback(err) { + if (err) { + return cb(err); + } var ctx = { Model: Model, data: context.data, diff --git a/test/manipulation.test.js b/test/manipulation.test.js index b2afdfe8..ab3313e6 100644 --- a/test/manipulation.test.js +++ b/test/manipulation.test.js @@ -606,6 +606,18 @@ describe('manipulation', function () { .catch(done); }); + it('should raises on connector error', function(done) { + var fakeConnector = { + updateAttributes: function (model, id, data, options, cb) { + cb(new Error('Database Error')); + } + }; + person.getConnector = function () { return fakeConnector; }; + person.updateAttributes({name: 'John'}, function(err, p) { + should.exist(err); + done(); + }); + }); }); describe('updateOrCreate', function() {