Skip to content

Commit 26c4a2b

Browse files
committed
CSHARP-2295: Deprecate group command helpers
1 parent 4816112 commit 26c4a2b

File tree

3 files changed

+17
-6
lines changed

3 files changed

+17
-6
lines changed

src/MongoDB.Driver.Core/Core/Misc/Feature.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public class Feature
5454
private static readonly Feature __findAndModifyWriteConcern = new Feature("FindAndModifyWriteConcern", new SemanticVersion(3, 2, 0));
5555
private static readonly Feature __findCommand = new Feature("FindCommand", new SemanticVersion(3, 2, 0));
5656
private static readonly Feature __geoNearCommand = new Feature("GeoNearCommand", new SemanticVersion(1, 0, 0), new SemanticVersion(4, 1, 0, ""));
57-
private static readonly Feature __groupCommand = new Feature("GroupCommand", new SemanticVersion(1, 0, 0), new SemanticVersion(4, 0, 0, "rc1"));
57+
private static readonly Feature __groupCommand = new Feature("GroupCommand", new SemanticVersion(1, 0, 0), new SemanticVersion(4, 1, 1, ""));
5858
private static readonly Feature __keepConnectionPoolWhenNotMasterConnectionException = new Feature("KeepConnectionPoolWhenNotMasterConnectionException", new SemanticVersion(4, 1, 10));
5959
private static readonly Feature __keepConnectionPoolWhenReplSetStepDown = new Feature("KeepConnectionPoolWhenReplSetStepDown", new SemanticVersion(4, 1, 10));
6060
private static readonly Feature __killCursorsCommand = new Feature("KillCursorsCommand", new SemanticVersion(3, 2, 0));

src/MongoDB.Driver.Legacy/MongoCollection.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1201,11 +1201,13 @@ public virtual CollectionStatsResult GetStats(GetStatsArgs args)
12011201
/// </summary>
12021202
/// <param name="args">The args.</param>
12031203
/// <returns>A list of results as BsonDocuments.</returns>
1204+
[Obsolete("The group command was deprecated in server version 3.4.")]
12041205
public virtual IEnumerable<BsonDocument> Group(GroupArgs args)
12051206
{
12061207
return UsingImplicitSession(session => Group(session, args));
12071208
}
12081209

1210+
[Obsolete("The group command was deprecated in server version 3.4.")]
12091211
private IEnumerable<BsonDocument> Group(IClientSessionHandle session, GroupArgs args)
12101212
{
12111213
if (args == null) { throw new ArgumentNullException("args"); }
@@ -1255,6 +1257,7 @@ private IEnumerable<BsonDocument> Group(IClientSessionHandle session, GroupArgs
12551257
/// <param name="reduce">A JavaScript function that is called for each matching document in a group.</param>
12561258
/// <param name="finalize">A JavaScript function that is called at the end of the group command.</param>
12571259
/// <returns>A list of results as BsonDocuments.</returns>
1260+
[Obsolete("The group command was deprecated in server version 3.4.")]
12581261
public virtual IEnumerable<BsonDocument> Group(
12591262
IMongoQuery query,
12601263
BsonJavaScript keyFunction,
@@ -1281,6 +1284,7 @@ public virtual IEnumerable<BsonDocument> Group(
12811284
/// <param name="reduce">A JavaScript function that is called for each matching document in a group.</param>
12821285
/// <param name="finalize">A JavaScript function that is called at the end of the group command.</param>
12831286
/// <returns>A list of results as BsonDocuments.</returns>
1287+
[Obsolete("The group command was deprecated in server version 3.4.")]
12841288
public virtual IEnumerable<BsonDocument> Group(
12851289
IMongoQuery query,
12861290
IMongoGroupBy keys,
@@ -1307,6 +1311,7 @@ public virtual IEnumerable<BsonDocument> Group(
13071311
/// <param name="reduce">A JavaScript function that is called for each matching document in a group.</param>
13081312
/// <param name="finalize">A JavaScript function that is called at the end of the group command.</param>
13091313
/// <returns>A list of results as BsonDocuments.</returns>
1314+
[Obsolete("The group command was deprecated in server version 3.4.")]
13101315
public virtual IEnumerable<BsonDocument> Group(
13111316
IMongoQuery query,
13121317
string key,

tests/MongoDB.Driver.Legacy.Tests/MongoCollectionTests.cs

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -892,7 +892,7 @@ public void TestDropIndex()
892892
public void TestDropIndexWriteConcern()
893893
{
894894
RequireServer.Check().Supports(Feature.AggregateOut, Feature.CommandsThatWriteAcceptWriteConcern).ClusterType(ClusterType.ReplicaSet);
895-
895+
896896
_collection.Drop();
897897
_collection.CreateIndex("x");
898898
var writeConcern = new WriteConcern(9, wTimeout: TimeSpan.FromMilliseconds(1));
@@ -2073,8 +2073,9 @@ public void TestGroupWithFinalizeFunction()
20732073
_collection.Insert(new BsonDocument("x", 3));
20742074
_collection.Insert(new BsonDocument("x", 3));
20752075
_collection.Insert(new BsonDocument("x", 3));
2076-
2076+
#pragma warning disable 618
20772077
var results = _collection.Group(new GroupArgs
2078+
#pragma warning restore
20782079
{
20792080
KeyFields = GroupBy.Keys("x"),
20802081
Initial = new BsonDocument("count", 0),
@@ -2102,8 +2103,9 @@ public void TestGroupWithKeyFields()
21022103
_collection.Insert(new BsonDocument("x", 3));
21032104
_collection.Insert(new BsonDocument("x", 3));
21042105
_collection.Insert(new BsonDocument("x", 3));
2105-
2106+
#pragma warning disable 618
21062107
var results = _collection.Group(new GroupArgs
2108+
#pragma warning restore
21072109
{
21082110
KeyFields = GroupBy.Keys("x"),
21092111
Initial = new BsonDocument("count", 0),
@@ -2130,8 +2132,9 @@ public void TestGroupWithKeyFunction()
21302132
_collection.Insert(new BsonDocument("x", 3));
21312133
_collection.Insert(new BsonDocument("x", 3));
21322134
_collection.Insert(new BsonDocument("x", 3));
2133-
2135+
#pragma warning disable 618
21342136
var results = _collection.Group(new GroupArgs
2137+
#pragma warning restore
21352138
{
21362139
KeyFunction = "function(doc) { return { x : doc.x }; }",
21372140
Initial = new BsonDocument("count", 0),
@@ -2168,7 +2171,9 @@ public void TestGroupWithMaxTime()
21682171
ReduceFunction = "function(doc, prev) { prev.count += 1 }",
21692172
MaxTime = TimeSpan.FromMilliseconds(1)
21702173
};
2174+
#pragma warning disable 618
21712175
Assert.Throws<MongoExecutionTimeoutException>(() => _collection.Group(args));
2176+
#pragma warning restore
21722177
}
21732178
}
21742179
}
@@ -2185,8 +2190,9 @@ public void TestGroupWithQuery()
21852190
_collection.Insert(new BsonDocument("x", 3));
21862191
_collection.Insert(new BsonDocument("x", 3));
21872192
_collection.Insert(new BsonDocument("x", 3));
2188-
2193+
#pragma warning disable 618
21892194
var results = _collection.Group(new GroupArgs
2195+
#pragma warning restore
21902196
{
21912197
Query = Query.LT("x", 3),
21922198
KeyFields = GroupBy.Keys("x"),

0 commit comments

Comments
 (0)