From 1fbe3bc18afc76cc7e97fbeeb680b6aecbd001ea Mon Sep 17 00:00:00 2001 From: Andre Rodrigues Date: Tue, 30 Apr 2013 15:55:08 +0100 Subject: [PATCH] Apply code review --- lib/services/table/tableservice.js | 31 +++++++++++++++++++---- test/services/table/tableservice-tests.js | 4 +-- 2 files changed, 28 insertions(+), 7 deletions(-) diff --git a/lib/services/table/tableservice.js b/lib/services/table/tableservice.js index 8f610d83e..1eb52288b 100644 --- a/lib/services/table/tableservice.js +++ b/lib/services/table/tableservice.js @@ -586,7 +586,11 @@ TableService.prototype.insertEntity = function (tableName, entityDescriptor, opt responseObject.insertResponse = null; if (!responseObject.error) { responseObject.insertResponse = entityResult.parse(responseObject.response.body.entry); - responseObject.insertResponse.etag = responseObject.response.headers[HeaderConstants.ETAG.toLowerCase()]; + if (!responseObject.insertResponse._) { + responseObject.insertResponse._ = {}; + } + + responseObject.insertResponse._.etag = responseObject.response.headers[HeaderConstants.ETAG.toLowerCase()]; } var finalCallback = function (returnObject) { @@ -641,7 +645,12 @@ TableService.prototype.insertOrReplaceEntity = function (tableName, entityDescri var processResponseCallback = function (responseObject, next) { responseObject.insertResponse = null; if (!responseObject.error) { - entityDescriptor.etag = responseObject.response.headers[HeaderConstants.ETAG.toLowerCase()]; + if (!entityDescriptor._) { + entityDescriptor._ = {}; + } + + entityDescriptor._.etag = responseObject.response.headers[HeaderConstants.ETAG.toLowerCase()]; + responseObject.entityResponse = entityDescriptor; } @@ -698,7 +707,11 @@ TableService.prototype.updateEntity = function (table, entityDescriptor, options var processResponseCallback = function (responseObject, next) { responseObject.entityResponse = null; if (!responseObject.error) { - entityDescriptor.etag = responseObject.response.headers[HeaderConstants.ETAG.toLowerCase()]; + if (!entityDescriptor._) { + entityDescriptor._ = {}; + } + entityDescriptor._.etag = responseObject.response.headers[HeaderConstants.ETAG.toLowerCase()]; + responseObject.entityResponse = entityDescriptor; } @@ -755,7 +768,11 @@ TableService.prototype.mergeEntity = function (tableName, entityDescriptor, opti var processResponseCallback = function (responseObject, next) { responseObject.entityResponse = null; if (!responseObject.error) { - entityDescriptor.etag = responseObject.response.headers[HeaderConstants.ETAG.toLowerCase()]; + if (!entityDescriptor._) { + entityDescriptor._ = {}; + } + + entityDescriptor._.etag = responseObject.response.headers[HeaderConstants.ETAG.toLowerCase()]; responseObject.entityResponse = entityDescriptor; } @@ -810,7 +827,11 @@ TableService.prototype.insertOrMergeEntity = function (tableName, entityDescript var processResponseCallback = function (responseObject, next) { responseObject.entityResponse = null; if (!responseObject.error) { - entityDescriptor.etag = responseObject.response.headers[HeaderConstants.ETAG.toLowerCase()]; + if (!entityDescriptor._) { + entityDescriptor._ = {}; + } + + entityDescriptor._.etag = responseObject.response.headers[HeaderConstants.ETAG.toLowerCase()]; responseObject.entityResponse = entityDescriptor; } diff --git a/test/services/table/tableservice-tests.js b/test/services/table/tableservice-tests.js index 95ba261e9..2bdf82097 100644 --- a/test/services/table/tableservice-tests.js +++ b/test/services/table/tableservice-tests.js @@ -468,7 +468,7 @@ suite('tableservice-tests', function () { assert.notEqual(insertEntity, null); assert.ok(insertResponse.isSuccessful); assert.equal(insertResponse.statusCode, HttpConstants.HttpResponseCodes.Created); - var originalEtag = newEntity1['etag']; + var originalEtag = newEntity1._.etag; newEntity1['otherfield'] = newField; @@ -477,7 +477,7 @@ suite('tableservice-tests', function () { assert.notEqual(updateEntity2, null); assert.ok(updateResponse2.isSuccessful); assert.equal(updateResponse2.statusCode, HttpConstants.HttpResponseCodes.NoContent); - assert.notEqual(newEntity1.etag, originalEtag); + assert.notEqual(newEntity1._.etag, originalEtag); done(); });