Skip to content

Commit 3578f30

Browse files
committed
CSHARP-1903: Aggregate cursor option is now required in latest server versions.
1 parent dfee4df commit 3578f30

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

src/MongoDB.Driver.Core/Core/Operations/AggregateOperation.cs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright 2013-2016 MongoDB Inc.
1+
/* Copyright 2013-2017 MongoDB Inc.
22
*
33
* Licensed under the Apache License, Version 2.0 (the "License");
44
* you may not use this file except in compliance with the License.
@@ -242,13 +242,18 @@ internal BsonDocument CreateCommand(SemanticVersion serverVersion)
242242
{ "collation", () => _collation.ToBsonDocument(), _collation != null }
243243
};
244244

245-
if (Feature.AggregateCursorResult.IsSupported(serverVersion) && _useCursor.GetValueOrDefault(true))
245+
if (Feature.AggregateCursorResult.IsSupported(serverVersion))
246246
{
247-
command["cursor"] = new BsonDocument
247+
var useCursor = _useCursor.GetValueOrDefault(true) || serverVersion >= new SemanticVersion(3, 5, 0);
248+
if (useCursor)
248249
{
249-
{ "batchSize", () => _batchSize.Value, _batchSize.HasValue }
250-
};
250+
command["cursor"] = new BsonDocument
251+
{
252+
{ "batchSize", () => _batchSize.Value, _batchSize.HasValue }
253+
};
254+
}
251255
}
256+
252257
return command;
253258
}
254259

src/MongoDB.Driver.Core/Core/Operations/AggregateToCollectionOperation.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright 2013-2016 MongoDB Inc.
1+
/* Copyright 2013-2017 MongoDB Inc.
22
*
33
* Licensed under the Apache License, Version 2.0 (the "License");
44
* you may not use this file except in compliance with the License.
@@ -196,7 +196,8 @@ internal BsonDocument CreateCommand(SemanticVersion serverVersion)
196196
{ "bypassDocumentValidation", () => _bypassDocumentValidation.Value, _bypassDocumentValidation.HasValue && Feature.BypassDocumentValidation.IsSupported(serverVersion) },
197197
{ "maxTimeMS", () => _maxTime.Value.TotalMilliseconds, _maxTime.HasValue },
198198
{ "collation", () => _collation.ToBsonDocument(), _collation != null },
199-
{ "writeConcern", () => _writeConcern.ToBsonDocument(), Feature.CommandsThatWriteAcceptWriteConcern.ShouldSendWriteConcern(serverVersion, _writeConcern) }
199+
{ "writeConcern", () => _writeConcern.ToBsonDocument(), Feature.CommandsThatWriteAcceptWriteConcern.ShouldSendWriteConcern(serverVersion, _writeConcern) },
200+
{ "cursor", new BsonDocument(), serverVersion >= new SemanticVersion(3, 5, 0) }
200201
};
201202
}
202203

0 commit comments

Comments
 (0)