Skip to content

Commit 7b487e5

Browse files
committed
Changed aggregate to ignore UseCursor when talking with a pre-2.6 server.
1 parent e5d696e commit 7b487e5

File tree

2 files changed

+3
-5
lines changed

2 files changed

+3
-5
lines changed

src/MongoDB.Driver.Core.Tests/Core/Operations/AggregateOperationTests.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,8 +143,7 @@ public void CreateCommand_should_create_the_correct_command(
143143
{ "maxTimeMS", () => maxTime.Value, maxTime.HasValue }
144144
};
145145

146-
var defaultCursorValue = semanticServerVersion >= new SemanticVersion(2, 6, 0);
147-
if (useCursor.GetValueOrDefault(defaultCursorValue))
146+
if (semanticServerVersion >= new SemanticVersion(2, 6, 0) && useCursor.GetValueOrDefault(true))
148147
{
149148
expectedResult["cursor"] = new BsonDocument
150149
{

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -200,8 +200,7 @@ internal BsonDocument CreateCommand(SemanticVersion serverVersion)
200200
{ "maxTimeMS", () => _maxTime.Value.TotalMilliseconds, _maxTime.HasValue }
201201
};
202202

203-
var defaultCursorValue = serverVersion >= __version26;
204-
if (_useCursor.GetValueOrDefault(defaultCursorValue))
203+
if (serverVersion >= __version26 && _useCursor.GetValueOrDefault(true))
205204
{
206205
command["cursor"] = new BsonDocument
207206
{
@@ -213,7 +212,7 @@ internal BsonDocument CreateCommand(SemanticVersion serverVersion)
213212

214213
private AsyncCursor<TResult> CreateCursor(IChannelSourceHandle channelSource, BsonDocument command, AggregateResult result)
215214
{
216-
if (_useCursor.GetValueOrDefault(true))
215+
if (channelSource.ServerDescription.Version >= __version26 && _useCursor.GetValueOrDefault(true))
217216
{
218217
return CreateCursorFromCursorResult(channelSource, command, result);
219218
}

0 commit comments

Comments
 (0)