Skip to content

Commit

Permalink
Fixed invalid collation in MongoDBJournal
Browse files Browse the repository at this point in the history
  • Loading branch information
sweetlandj committed Feb 13, 2018
1 parent cfda0eb commit 1540b59
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions Source/Platibus.MongoDB/MongoDBMessageJournal.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ namespace Platibus.MongoDB
/// </summary>
public class MongoDBMessageJournal : IMessageJournal
{
private static readonly Collation Collation = new Collation("simple", strength: CollationStrength.Secondary);
private readonly Collation _collation = new Collation("simple");

/// <summary>
/// The default name of the collection that will be used to store message journal entries
Expand Down Expand Up @@ -85,6 +85,10 @@ public MongoDBMessageJournal(ConnectionStringSettings connectionStringSettings,

var minServerVersion = database.Client.Cluster.Description.Servers.Min(s => s.Version);
_collationSupported = Feature.Collation.IsSupported(minServerVersion);
if (_collationSupported)
{
_collation = new Collation("en", strength: CollationStrength.Secondary);
}

_diagnosticService = diagnosticService ?? DiagnosticService.DefaultInstance;

Expand All @@ -97,7 +101,7 @@ private void CreateIndexes()
var options = new CreateIndexOptions();
if (_collationSupported)
{
options.Collation = Collation;
options.Collation = _collation;
}

TryCreateIndex(ikb.Ascending(c => c.Category), "category_1");
Expand All @@ -118,7 +122,7 @@ private void TryCreateIndex(IndexKeysDefinition<MessageJournalEntryDocument> ind

if (_collationSupported)
{
options.Collation = Collation;
options.Collation = _collation;
}

try
Expand Down Expand Up @@ -185,7 +189,7 @@ public Task<MessageJournalPosition> GetBeginningOfJournal(CancellationToken canc
var options = new FindOptions();
if (_collationSupported)
{
options.Collation = Collation;
options.Collation = _collation;
}

var entryDocuments = await _messageJournalEntries.Find(filterDef, options)
Expand Down

0 comments on commit 1540b59

Please sign in to comment.