Fix regression in prototype.save

ffcaa4e7 added a "data" argument to the callback function, which
shadowed the original data with the data returned by a connector.
Not all connectors are returning a data object though, in which case
the model instance ("this" object) is updated with wrong values.

This commit fixes the problem by renaming the second callback argument
to "unusedData".
This commit is contained in:
Miroslav Bajtoš 2015-03-23 08:34:21 +01:00
parent 99396387ee
commit f7dc6fab90
2 changed files with 2 additions and 1 deletions

View File

@ -1587,7 +1587,7 @@ DataAccessObject.prototype.save = function (options, cb) {
inst.trigger('save', function (saveDone) {
inst.trigger('update', function (updateDone) {
data = removeUndefined(data);
inst._adapter().save(modelName, inst.constructor._forDB(data), function (err, data, result) {
inst._adapter().save(modelName, inst.constructor._forDB(data), function (err, unusedData, result) {
if (err) {
return cb(err, inst);
}

View File

@ -340,6 +340,7 @@ describe('manipulation', function () {
p.name = 'Hans';
p.save(function (err) {
should.not.exist(err);
p.name.should.equal('Hans');
Person.findOne(function (err, p) {
should.not.exist(err);
p.name.should.equal('Hans');