Skip to content

Commit

Permalink
update mongo drivers
Browse files Browse the repository at this point in the history
  • Loading branch information
tmm360 committed Sep 19, 2024
1 parent 4d4f1bb commit 16fb5b0
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 17 deletions.
9 changes: 3 additions & 6 deletions src/MongODM.Core/FieldDefinition/MemberMapFieldDefinition.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public MemberMapFieldDefinition(
public bool ReferToFinalItem { get; }

// Methods.
public override RenderedFieldDefinition Render(IBsonSerializer<TDocument> documentSerializer, IBsonSerializerRegistry serializerRegistry, LinqProvider linqProvider) =>
public override RenderedFieldDefinition Render(RenderArgs<TDocument> args) =>
new(MemberMap.RenderElementPath(
ReferToFinalItem,
undefinedArrayIndexSymbolSelector,
Expand Down Expand Up @@ -103,18 +103,15 @@ public MemberMapFieldDefinition(
public bool ReferToFinalItem { get; }

// Methods.
public override RenderedFieldDefinition<TField> Render(IBsonSerializer<TDocument> documentSerializer, IBsonSerializerRegistry serializerRegistry, LinqProvider linqProvider) =>
Render(documentSerializer, serializerRegistry, linqProvider, false);

public override RenderedFieldDefinition<TField> Render(IBsonSerializer<TDocument> documentSerializer, IBsonSerializerRegistry serializerRegistry, LinqProvider linqProvider, bool allowScalarValueForArrayField)
public override RenderedFieldDefinition<TField> Render(RenderArgs<TDocument> args)
{
IBsonSerializer<TField> valueSerializer =
customFieldSerializer ??
(IBsonSerializer<TField>)FieldValueSerializerHelper.GetSerializerForValueType(
MemberMap.Serializer,
MemberMap.DbContext.SerializerRegistry,
typeof(TField),
allowScalarValueForArrayField);
args.PathRenderArgs.AllowScalarValueForArray);

return new RenderedFieldDefinition<TField>(
MemberMap.RenderElementPath(
Expand Down
12 changes: 6 additions & 6 deletions src/MongODM.Core/FieldDefinition/UnmappedFieldDefinition.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ public UnmappedFieldDefinition(
public IBsonSerializer UnmappedFieldSerializer { get; }

// Methods.
public override RenderedFieldDefinition Render(IBsonSerializer<TDocument> documentSerializer, IBsonSerializerRegistry serializerRegistry, LinqProvider linqProvider) =>
new(UnmappedFieldDefinitionHelper.BuildFieldPath(BaseDocumentField, UnmappedFieldName, documentSerializer, serializerRegistry, linqProvider),
public override RenderedFieldDefinition Render(RenderArgs<TDocument> args) =>
new(UnmappedFieldDefinitionHelper.BuildFieldPath(BaseDocumentField, UnmappedFieldName, args.DocumentSerializer, args.SerializerRegistry, args.LinqProvider),
UnmappedFieldSerializer);

public Type? TryGetBaseDocumentType(IBsonSerializer<TDocument> documentSerializer, IBsonSerializerRegistry serializerRegistry) =>
Expand Down Expand Up @@ -74,8 +74,8 @@ public UnmappedFieldDefinition(
public IBsonSerializer<TField> UnmappedFieldSerializer { get; }

// Methods.
public override RenderedFieldDefinition<TField> Render(IBsonSerializer<TDocument> documentSerializer, IBsonSerializerRegistry serializerRegistry, LinqProvider linqProvider) =>
new(UnmappedFieldDefinitionHelper.BuildFieldPath(BaseDocumentField, UnmappedFieldName, documentSerializer, serializerRegistry, linqProvider),
public override RenderedFieldDefinition<TField> Render(RenderArgs<TDocument> args) =>
new(UnmappedFieldDefinitionHelper.BuildFieldPath(BaseDocumentField, UnmappedFieldName, args.DocumentSerializer, args.SerializerRegistry, args.LinqProvider),
UnmappedFieldSerializer,
UnmappedFieldSerializer,
UnmappedFieldSerializer);
Expand All @@ -96,7 +96,7 @@ public static string BuildFieldPath<TDocument>(
var sb = new StringBuilder();
if (baseDocumentField is not null)
{
var baseDocRenderedField = baseDocumentField.Render(documentSerializer, serializerRegistry, linqProvider);
var baseDocRenderedField = baseDocumentField.Render(new(documentSerializer, serializerRegistry, linqProvider));
sb.Append(baseDocRenderedField.FieldName);
}
if (sb.Length > 0)
Expand All @@ -114,7 +114,7 @@ public static string BuildFieldPath<TDocument>(
if (baseDocumentField is null)
return null;

var renderedBaseDocumentField = baseDocumentField.Render(documentSerializer, serializerRegistry);
var renderedBaseDocumentField = baseDocumentField.Render(new(documentSerializer, serializerRegistry));
var baseDocumentFieldSerializer = renderedBaseDocumentField.FieldSerializer;

// Until serializer is an array serializer, go down to its item serializer.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,13 @@ public MemberMapEqFilterDefinition(
}

// Methods.
public override BsonDocument Render(IBsonSerializer<TDocument> documentSerializer, IBsonSerializerRegistry serializerRegistry, LinqProvider linqProvider)
public override BsonDocument Render(RenderArgs<TDocument> args)
{
var memberMapFieldDefinition = new MemberMapFieldDefinition<TDocument, TItem>(
memberMap,
_ => $".{ElemMatchCommand}",
_ => throw new MongodmElementPathRenderingException());
var renderedField = memberMapFieldDefinition.Render(documentSerializer, serializerRegistry, linqProvider);
var renderedField = memberMapFieldDefinition.Render(args);
var segmentedField = renderedField.FieldName.Split('.');
var filterDocument = BuildBsonDocument(segmentedField, value, renderedField.ValueSerializer);
return filterDocument;
Expand Down
2 changes: 1 addition & 1 deletion src/MongODM.Core/MongODM.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

<ItemGroup>
<PackageReference Include="Castle.Core" Version="5.1.1" />
<PackageReference Include="Etherna.MongoDB.Driver" Version="2.28.3" />
<PackageReference Include="Etherna.MongoDB.Driver" Version="2.29.0" />
<PackageReference Include="ExecutionContext" Version="1.3.0" />
<PackageReference Include="GitVersion.MsBuild" Version="5.12.0">
<PrivateAssets>all</PrivateAssets>
Expand Down
4 changes: 2 additions & 2 deletions src/MongODM.Core/Repositories/Repository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ public virtual Task BuildIndexesAsync(CancellationToken cancellationToken = defa
{
try
{
var renderedKeys = keys.Render(collection.DocumentSerializer, collection.Settings.SerializerRegistry);
var renderedKeys = keys.Render(new(collection.DocumentSerializer, collection.Settings.SerializerRegistry));
options.Name = $"doc_{string.Join("_", renderedKeys.Names)}";
}
catch (InvalidOperationException)
Expand Down Expand Up @@ -419,7 +419,7 @@ public virtual Task ReplaceAsync(
AccessToCollectionAsync(async collection =>
{
var modelMap = DbContext.MapRegistry.GetModelMap(typeof(TModel));
var fieldRendered = setField.Render((IBsonSerializer<TModel>)modelMap.ActiveSerializer, DbContext.SerializerRegistry);
var fieldRendered = setField.Render(new((IBsonSerializer<TModel>)modelMap.ActiveSerializer, DbContext.SerializerRegistry));

// Serialize model.
var modelBsonDoc = new BsonDocument();
Expand Down

0 comments on commit 16fb5b0

Please sign in to comment.