Skip to content

Commit

Permalink
Upgrade MongoDB.Driver dependency to version 2.21.0 (#87)
Browse files Browse the repository at this point in the history
* Upgrade MongoDB.Driver dependency to version 2.21.0

Version 2.21.0 of [MongoDB.Driver][1] introduced a [breaking change][2] by adding a `SearchIndexes` property to the `IMongoCollection` interface.

This commit implements this new property in order to avoid the following exception:

> **System.TypeLoadException**
> Method 'get_SearchIndexes' in type 'MongoDB.Extensions.Transactions.MongoTransactionCollection`1' from assembly 'MongoDB.Extensions.Transactions, Version=3.1.0.0, Culture=neutral, PublicKeyToken=null' does not have an implementation.

[1]: https://www.nuget.org/packages/MongoDB.Driver/2.21.0
[2]: https://jira.mongodb.org/browse/CSHARP-4660?focusedCommentId=5628278&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#comment-5628278

* Fix brittle test by excluding fields that are not relevant and which may change

* Exclude the whole execStats from the snapshot

This can change dramatically between mongo versions. This is exactly what happened when pulling mongo:latest a few days apart.
  • Loading branch information
0xced authored Aug 23, 2023
1 parent 7a50ef3 commit 45c80b2
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 22 deletions.
2 changes: 1 addition & 1 deletion Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
</ItemGroup>

<ItemGroup>
<PackageVersion Include="MongoDB.Driver" Version="2.19.0" />
<PackageVersion Include="MongoDB.Driver" Version="2.21.0" />
<PackageVersion Include="MongoDB.Driver.Core.Extensions.DiagnosticSources" Version="1.3.0" />
<PackageVersion Include="System.Text.Json" Version="7.0.0" />
</ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/Prime.Extensions.Tests/MongoDatabaseExtensionsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -197,9 +197,9 @@ public void GetProfiledOperations_GetAllExecutedOperations_ReturnsAllMongoDBOper
.IncludeField("**.keysExamined")
.IncludeField("**.docsExamined")
.IncludeField("**.planSummary")
.IncludeField("**.execStats")
.ExcludeField("**.$db")
.ExcludeField("**.lsid")
.ExcludeField("execStats")
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,25 +33,6 @@
},
"keysExamined": 0,
"docsExamined": 1,
"planSummary": "COLLSCAN",
"execStats": {
"stage": "COLLSCAN",
"filter": {
"Name": {
"$eq": "foo1"
}
},
"nReturned": 0,
"executionTimeMillisEstimate": 0,
"works": 3,
"advanced": 0,
"needTime": 2,
"needYield": 0,
"saveState": 0,
"restoreState": 0,
"isEOF": 1,
"direction": "forward",
"docsExamined": 1
}
"planSummary": "COLLSCAN"
}
]
3 changes: 3 additions & 0 deletions src/Transactions/MongoTransactionCollection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using MongoDB.Bson;
using MongoDB.Bson.Serialization;
using MongoDB.Driver;
using MongoDB.Driver.Search;

#pragma warning disable 618

Expand Down Expand Up @@ -1081,6 +1082,8 @@ public IMongoCollection<T> WithWriteConcern(WriteConcern writeConcern)

public IMongoIndexManager<T> Indexes => _collection.Indexes;

public IMongoSearchIndexManager SearchIndexes => _collection.SearchIndexes;

public MongoCollectionSettings Settings => _collection.Settings;

private bool TryGetSession(out IClientSessionHandle sessionHandle)
Expand Down

0 comments on commit 45c80b2

Please sign in to comment.