Skip to content

Commit 3951103

Browse files
committed
add median feature and undo accidental change
1 parent 534f650 commit 3951103

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ public class Feature
8383
private static readonly Feature __loookupConciseSyntax = new Feature("LoookupConciseSyntax", WireVersion.Server50);
8484
private static readonly Feature __loookupDocuments= new Feature("LoookupDocuments", WireVersion.Server60);
8585
private static readonly Feature __mmapV1StorageEngine = new Feature("MmapV1StorageEngine", WireVersion.Zero, WireVersion.Server42);
86+
private static readonly Feature __medianOperator = new Feature("MedianOperator", WireVersion.Server70);
8687
private static readonly Feature __percentileOperator = new Feature("PercentileOperator", WireVersion.Server70);
8788
private static readonly Feature __pickAccumulatorsNewIn52 = new Feature("PickAccumulatorsNewIn52", WireVersion.Server52);
8889
private static readonly Feature __rankFusionStage = new Feature("RankFusionStage", WireVersion.Server81);
@@ -402,6 +403,11 @@ public class Feature
402403
[Obsolete("This feature was removed in server version 4.2. As such, this property will be removed in a later release.")]
403404
public static Feature MmapV1StorageEngine => __mmapV1StorageEngine;
404405

406+
/// <summary>
407+
/// Gets the $median operator added in 7.0
408+
/// </summary>
409+
public static Feature MedianOperator => __medianOperator;
410+
405411
/// <summary>
406412
/// Gets the $percentile operator added in 7.0
407413
/// </summary>

tests/MongoDB.Driver.Tests/Linq/Linq3Implementation/Translators/ExpressionToAggregationExpressionTranslators/MethodTranslators/MedianMethodToAggregationExpressionTranslatorTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ namespace MongoDB.Driver.Tests.Linq.Linq3Implementation.Translators.ExpressionTo
2929
public class MedianMethodToAggregationExpressionTranslatorTests : LinqIntegrationTest<MedianMethodToAggregationExpressionTranslatorTests.ClassFixture>
3030
{
3131
public MedianMethodToAggregationExpressionTranslatorTests(ClassFixture fixture)
32-
: base(fixture, server => server.Supports(Feature.PercentileOperator)) // median and percentile were added in the same server version
32+
: base(fixture, server => server.Supports(Feature.MedianOperator))
3333
{
3434
}
3535

tests/MongoDB.Driver.Tests/Linq/Linq3ImplementationWithLinq2Tests/Translators/AggregateGroupTranslatorTests.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ public void Should_translate_count_with_a_predicate()
168168
[Fact]
169169
public void Should_translate_median_with_embedded_projector()
170170
{
171-
RequireServer.Check().Supports(Feature.PercentileOperator);
171+
RequireServer.Check().Supports(Feature.MedianOperator);
172172

173173
var result = Group(x => x.A, g => new { Result = g.Median(x=> x.C.E.F) });
174174

@@ -183,7 +183,7 @@ public void Should_translate_median_with_embedded_projector()
183183
[Fact]
184184
public void Should_translate_median_with_selected_projector()
185185
{
186-
RequireServer.Check().Supports(Feature.PercentileOperator);
186+
RequireServer.Check().Supports(Feature.MedianOperator);
187187

188188
var result = Group(x => x.A, g => new { Result = g.Select(x => x.C.E.F).Median() });
189189

@@ -567,7 +567,7 @@ public void Should_translate_complex_selector()
567567
First : '$__agg2',
568568
Last : '$__agg3',
569569
Min : '$__agg4',
570-
Max : '$__agg5'
570+
Max : '$__agg5',
571571
_id : 0
572572
}
573573
}");

0 commit comments

Comments
 (0)