[CSHARP-4488] Discriminator is lost when using ObjectUpdateDefinition<T> Created: 24/Jan/23  Updated: 24/Jul/23

Status: Backlog
Project: C# Driver
Component/s: BSON
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Martin Plücker Assignee: Unassigned
Resolution: Unresolved Votes: 0
Labels: triage
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 Description   

Summary

When updating a document with polymorphic type TDocument and known sub type TSubType using an ObjectUpdateDefinition the type discriminator is lost.

Version: C# Driver: 2.17.1

How to Reproduce

  • Use FindOneAndUpdateAsync on a document with polymorphic type using an _ObjectUpdateDefinition_

Additional Background

The Render method of ObjectUpdateDefinition<T> resolved the serializer from the type of the object but ignores the documentSerializer which should be used. Thus, the serializer of the TSubType is picked which does not add the type discriminator.



 Comments   
Comment by Martin Plücker [ 24/Jul/23 ]

Is there any update?

Comment by Martin Plücker [ 14/Feb/23 ]

Hi, you can find a reproducer and my proposed fix on GitHub:

algompluecker/mongodb_CSHARP-4488: Showcase for issue CSHARP-4488 (github.com)

Comment by Dmitry Lukyanov (Inactive) [ 06/Feb/23 ]

Hey martin.pluecker@algominds.de, can you please provide a small repro for your case?

Comment by Martin Plücker [ 24/Jan/23 ]

The issue is also present in the latest driver version 2.18,0

Generated at Wed Feb 07 21:48:22 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.