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:
parent
99396387ee
commit
f7dc6fab90
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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');
|
||||
|
|
Loading…
Reference in New Issue