Skip to content

Commit 98bd11c

Browse files
rstamcraiggwilson
rstam
authored andcommitted
CSHARP-987: Code review changes.
1 parent 899f52e commit 98bd11c

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

MongoDB.Driver/Operations/BulkWriteBatchResult.cs

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,9 @@
1313
* limitations under the License.
1414
*/
1515

16-
using System;
1716
using System.Collections.Generic;
1817
using System.Collections.ObjectModel;
1918
using System.Linq;
20-
using System.Text;
2119
using MongoDB.Bson;
2220
using MongoDB.Driver.Support;
2321

@@ -260,11 +258,13 @@ public static BulkWriteBatchResult Create(
260258
var unprocessedRequests = Enumerable.Empty<WriteRequest>();
261259
BsonValue upsertId = null;
262260
var documentsAffected = 0L;
263-
if(writeConcernResult != null)
261+
262+
if (writeConcernResult != null)
264263
{
265-
documentsAffected = writeConcernResult.DocumentsAffected;
266264
upsertId = writeConcernResult.Upserted;
265+
documentsAffected = writeConcernResult.DocumentsAffected;
267266
var updateRequest = request as UpdateRequest;
267+
268268
if (upsertId == null &&
269269
documentsAffected == 1 &&
270270
updateRequest != null &&
@@ -273,13 +273,12 @@ public static BulkWriteBatchResult Create(
273273
{
274274
// Get the _id field first from the Update document
275275
// and then from the Query document.
276-
upsertId = updateRequest.Update.ToBsonDocument()
277-
.GetValue(
278-
"_id",
279-
updateRequest.Query.ToBsonDocument()
280-
.GetValue("_id", null));
276+
upsertId =
277+
updateRequest.Update.ToBsonDocument().GetValue("_id", null) ??
278+
updateRequest.Query.ToBsonDocument().GetValue("_id", null);
281279
}
282280
}
281+
283282
var upserts = (upsertId == null) ? Enumerable.Empty<BulkWriteUpsert>() : new[] { new BulkWriteUpsert(0, upsertId) };
284283
var writeErrors = __noWriteErrors;
285284
WriteConcernError writeConcernError = null;

0 commit comments

Comments
 (0)