-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Closed
Labels
.NETIssue or Pull requests regarding .NET codeIssue or Pull requests regarding .NET codeBuildFeatures planned for next Build conferenceFeatures planned for next Build conferencemsft.ext.vectordataRelated to Microsoft.Extensions.VectorDataRelated to Microsoft.Extensions.VectorData
Description
Our upsert APIs currently return a TKey (or an IReadOnlyList<TKey>
for the batching version); this was done to enable database-generated keys (e.g. identity columns in SQL Server).
After discussion, we think MEVD connectors should inject database-generated keys rather than return them; this would mean that we change the Upsert method signatures to return a simple Task (no return value).
Notes:
- The user experience is much better if users can simply access generated keys on their respective records. For example, if the keys are returned, the user must take care to access the correct key in the returned list, which correlates to the right record etc. FWIW this is also what EF does.
- Database-generated keys aren't supported by all databases, and every where they are, may not be desirable in all scenarios. For those cases, the upsert return value is useless and can be confusing to users. Simply having the keys injected is a way to achieve the same goal without impacting the method signature.
- It might seem slightly odd that MEVD mutates the upserted record. However, it's worth mentioning that database-generation keys will generally be an opt-in (a user gesture will be required when configuring the key property), and so that also opts into the mutation. Also, any EF users will also be familiar with this behavior.
- We allow record types to be structs, but in order to mutate a struct, it must be passed in as
ref
. We considered the various options here (introduce an overload accepting aref
, disallowing struct record types), and decided that for the edge case of a struct record with auto-generated keys, we'll simply throw at runtime (this disallows only the presumably very narrow intersection of struct + database key generation, without affecting the vast majority of users that don't fall into that).
Metadata
Metadata
Assignees
Labels
.NETIssue or Pull requests regarding .NET codeIssue or Pull requests regarding .NET codeBuildFeatures planned for next Build conferenceFeatures planned for next Build conferencemsft.ext.vectordataRelated to Microsoft.Extensions.VectorDataRelated to Microsoft.Extensions.VectorData
Type
Projects
Status
Sprint: Done