Fix for beforeSave with increment causing key to be Dropped (#4259)

* Fixes an issue where a beforeSave hook could cause a numeric val to be dropped in response.

* Use hasOwnProperty to check instead

* Remove redundant set
This commit is contained in:
Benjamin Wilson Friedman
2017-10-15 21:15:30 -07:00
committed by GitHub
parent 557a2b2827
commit 315d30b426
2 changed files with 42 additions and 2 deletions

View File

@@ -1195,9 +1195,10 @@ RestWrite.prototype._updateResponseWithData = function(response, data) {
const clientSupportsDelete = ClientSDK.supportsForwardDelete(this.clientSDK);
this.storage.fieldsChangedByTrigger.forEach(fieldName => {
const dataValue = data[fieldName];
const responseValue = response[fieldName];
response[fieldName] = responseValue || dataValue;
if(!response.hasOwnProperty(fieldName)) {
response[fieldName] = dataValue;
}
// Strips operations from responses
if (response[fieldName] && response[fieldName].__op) {