UpdateAttributes: Raises an error if database fails

Signed-off-by: Wilson Júnior <wilsonpjunior@gmail.com>
This commit is contained in:
Wilson Júnior 2015-11-17 17:02:43 -02:00
parent 5ca9c47f44
commit c26b857a87
2 changed files with 15 additions and 0 deletions

View File

@ -2449,6 +2449,9 @@ DataAccessObject.prototype.updateAttributes = function updateAttributes(data, op
context.data = typedData; context.data = typedData;
function updateAttributesCallback(err) { function updateAttributesCallback(err) {
if (err) {
return cb(err);
}
var ctx = { var ctx = {
Model: Model, Model: Model,
data: context.data, data: context.data,

View File

@ -606,6 +606,18 @@ describe('manipulation', function () {
.catch(done); .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() { describe('updateOrCreate', function() {