Skip to content

Commit dbea92c

Browse files
committed
CSHARP-4140: Skip $getField tests on older servers.
1 parent a43d040 commit dbea92c

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

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

+6
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ public class Feature
6969
private static readonly Feature __findAndModifyWriteConcern = new Feature("FindAndModifyWriteConcern", WireVersion.Server32);
7070
private static readonly Feature __findCommand = new Feature("FindCommand", WireVersion.Server32);
7171
private static readonly Feature __geoNearCommand = new Feature("GeoNearCommand", WireVersion.Zero, WireVersion.Server42);
72+
private static readonly Feature __getField = new Feature("GetField", WireVersion.Server50);
7273
private static readonly Feature __getMoreComment = new Feature("GetMoreComment", WireVersion.Server44);
7374
private static readonly Feature __groupCommand = new Feature("GroupCommand", WireVersion.Zero, WireVersion.Server42);
7475
private static readonly Feature __hedgedReads = new Feature("HedgedReads", WireVersion.Server44);
@@ -369,6 +370,11 @@ public class Feature
369370
/// </summary>
370371
public static Feature GeoNearCommand => __geoNearCommand;
371372

373+
/// <summary>
374+
/// Gets the getField feature.
375+
/// </summary>
376+
public static Feature GetField => __getField;
377+
372378
/// <summary>
373379
/// Gets the getMore comment feature.
374380
/// </summary>

tests/MongoDB.Driver.Tests/Linq/Linq3ImplementationTests/Jira/CSharp4140Tests.cs

+6
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
using System.Linq;
1717
using FluentAssertions;
1818
using MongoDB.Bson;
19+
using MongoDB.Driver.Core.Misc;
20+
using MongoDB.Driver.Core.TestHelpers.XunitExtensions;
1921
using Xunit;
2022

2123
namespace MongoDB.Driver.Tests.Linq.Linq3ImplementationTests.Jira
@@ -48,6 +50,8 @@ public void Should_not_use_getField(string fieldName)
4850
[InlineData("a.")]
4951
public void Should_use_getField(string fieldName)
5052
{
53+
RequireServer.Check().Supports(Feature.GetField);
54+
5155
var collection = GetCollection<BsonDocument>();
5256
CreateCollection(collection, new BsonDocument(fieldName, 123));
5357
var queryable = collection.AsQueryable()
@@ -67,6 +71,8 @@ public void Should_use_getField(string fieldName)
6771
[InlineData("$a$")]
6872
public void Should_use_getField_with_literal(string fieldName)
6973
{
74+
RequireServer.Check().Supports(Feature.GetField);
75+
7076
var collection = GetCollection<BsonDocument>();
7177
CreateCollection(collection, new BsonDocument(fieldName, 123));
7278
var queryable = collection.AsQueryable()

0 commit comments

Comments
 (0)