-
Notifications
You must be signed in to change notification settings - Fork 4.4k
.Net: Switch MEVD MongoDB Driver to v3.51 #13370
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
This means targetting .NET 4.7.2 for vector data implementations that depend on it. Supressed warnings about disposal since it doesn't do anything yet. # Conflicts: # dotnet/Directory.Packages.props
roji
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great to see this @damieng, thanks. All looks good, see mainly the question about netstandard2.1 and some nits.
| return handler; | ||
| } | ||
| #elif NET462 | ||
| #elif NET462 || NET472 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe just do #elif NETFRAMEWORK?
| { | ||
| if (value is null) | ||
| { | ||
| return BsonNull.Value; | ||
| } | ||
|
|
||
| if (value.GetType().IsArray) | ||
| { | ||
| if (value is Guid[] guids) | ||
| { | ||
| return new BsonArray(Array.ConvertAll(guids, x => new BsonBinaryData(x, GuidRepresentation.Standard))); | ||
| } | ||
|
|
||
| return new BsonArray(value as Array); | ||
| } | ||
|
|
||
| if (value is Guid guid) | ||
| { | ||
| return new BsonBinaryData(guid, GuidRepresentation.Standard); | ||
| } | ||
|
|
||
| return BsonValue.Create(value); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: am addicted to switch expressions:
| { | |
| if (value is null) | |
| { | |
| return BsonNull.Value; | |
| } | |
| if (value.GetType().IsArray) | |
| { | |
| if (value is Guid[] guids) | |
| { | |
| return new BsonArray(Array.ConvertAll(guids, x => new BsonBinaryData(x, GuidRepresentation.Standard))); | |
| } | |
| return new BsonArray(value as Array); | |
| } | |
| if (value is Guid guid) | |
| { | |
| return new BsonBinaryData(guid, GuidRepresentation.Standard); | |
| } | |
| return BsonValue.Create(value); | |
| } | |
| => value switch | |
| { | |
| null => BsonNull.Value, | |
| Guid guid => new BsonBinaryData(guid, GuidRepresentation.Standard), | |
| Guid[] guids => new BsonArray(Array.ConvertAll(guids, x => new BsonBinaryData(x, GuidRepresentation.Standard))), | |
| Array array => new BsonArray(array), | |
| _ => BsonValue.Create(value) | |
| }; |
| <AssemblyName>Microsoft.SemanticKernel.Connectors.MongoDB</AssemblyName> | ||
| <RootNamespace>$(AssemblyName)</RootNamespace> | ||
| <TargetFrameworks>net8.0;netstandard2.0;net462</TargetFrameworks> | ||
| <TargetFrameworks>net8.0;net472</TargetFrameworks> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this also target netstandard2.1, given that MongoDB.Driver targets that? There probably isn't huge value in doing so, but then the MEVD provider is supposed to be a simple layer on top of the driver, so ideally would support whatever the driver supports... Also it's probably pretty trivial to add.
Motivation and Context
Switches the MongoDB Driver to the latest 3.5 release which had a number of breaking changes.
This affects both the MongoDB vector data project and the CosmosMongoDB project.
This fixes #11652 and likely addresses #12707 and partly #10291.
Description
Switches the MongoDB driver to 3.5. Part of the breaking changes is that GUIDs in BSON no longer have a default storage format specified due to the need to switch from the C#-only format to the cross-MongoDB-driver standard format. Setting this is achieved in this PR by way of both a convention for the registry based mode and an alternative to BsonValue.Create in the scenarios where we don't have access to conventions/serialization such as key creation and using the dynamic mapper.
Contribution Checklist
cc @roji