Skip to content

Commit 13c40e7

Browse files
author
rstam
committed
CSHARP-942: Throw a NotSupportedException if the Exhaust query flag is used.
1 parent c148671 commit 13c40e7

File tree

3 files changed

+40
-0
lines changed

3 files changed

+40
-0
lines changed

MongoDB.Driver/Communication/Messages/MongoQueryMessage.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,11 @@ internal override void WriteBodyTo(BsonBuffer buffer)
7878

7979
internal override void WriteHeaderTo(BsonBuffer buffer)
8080
{
81+
if ((_flags & QueryFlags.Exhaust) != 0)
82+
{
83+
throw new NotSupportedException("The Exhaust QueryFlag is not yet supported.");
84+
}
85+
8186
base.WriteHeaderTo(buffer);
8287
buffer.WriteInt32((int)_flags);
8388
buffer.WriteCString(new UTF8Encoding(false, true), _collectionFullName);
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/* Copyright 2010-2014 MongoDB Inc.
2+
*
3+
* Licensed under the Apache License, Version 2.0 (the "License");
4+
* you may not use this file except in compliance with the License.
5+
* You may obtain a copy of the License at
6+
*
7+
* http://www.apache.org/licenses/LICENSE-2.0
8+
*
9+
* Unless required by applicable law or agreed to in writing, software
10+
* distributed under the License is distributed on an "AS IS" BASIS,
11+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
* See the License for the specific language governing permissions and
13+
* limitations under the License.
14+
*/
15+
16+
using System;
17+
using System.Linq;
18+
using MongoDB.Driver;
19+
using NUnit.Framework;
20+
21+
namespace MongoDB.DriverUnitTests.Jira
22+
{
23+
[TestFixture]
24+
public class CSharp942Tests
25+
{
26+
[Test]
27+
public void TestExhaustQueryFlagThrowsException()
28+
{
29+
var collection = Configuration.TestCollection;
30+
var cursor = collection.FindAll().SetFlags(QueryFlags.Exhaust);
31+
Assert.Throws<NotSupportedException>(() => cursor.ToList());
32+
}
33+
}
34+
}

MongoDB.DriverUnitTests/MongoDB.DriverUnitTests.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@
134134
<Compile Include="Jira\CSharp653Tests.cs" />
135135
<Compile Include="Jira\CSharp714Tests.cs" />
136136
<Compile Include="Jira\CSharp718Tests.cs" />
137+
<Compile Include="Jira\CSharp942Tests.cs" />
137138
<Compile Include="Jira\CSharp779Tests.cs" />
138139
<Compile Include="Jira\CSharp801Tests.cs" />
139140
<Compile Include="Jira\CSharp840Tests.cs" />

0 commit comments

Comments
 (0)