[CSHARP-2009] Discriminator incorrect when using "OfType<>" Created: 27/Jun/17 Updated: 28/Oct/23 Resolved: 02/Feb/21 |
|
| Status: | Closed |
| Project: | C# Driver |
| Component/s: | Serialization |
| Affects Version/s: | 2.4.4 |
| Fix Version/s: | 2.12.0 |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | Martin Lobger | Assignee: | Boris Dogadov |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Attachments: |
|
||||||||
| Issue Links: |
|
||||||||
| Description |
|
When using OfType<TDerived> on a collection, the "ofTypeFilter" filter of the returned IFilteredMongoCollection<TDerivedDocument> does not generate a correct discriminator. Consider this:
The "collection" variable will be of type IFilteredMongoCollection<B> with an internal "ofTypeFilter" generating a discriminator looking like this:
where it should have looked like this:
Ultimately this leads to a problem when using "upsert". Since parts of the document inserted comes from the filter, the discriminator does so as well. Since it is incorrect rendered, it leads to document in mongo with a wrong discriminator. Attached is a small program that reveals the problem. |
| Comments |
| Comment by Githook User [ 02/Feb/21 ] |
|
Author: {'name': 'Boris', 'email': 'boris.dogadov@mongodb.com', 'username': 'BorisDog'}Message: |
| Comment by Martin Lobger [ 29/Jun/17 ] |
|
Well, after some deeper digging into this issue, I have realized that fixing the filter is not the way to go. I have updated the pull request #284, so that it targets the actual upsert issue more specific. |
| Comment by Martin Lobger [ 27/Jun/17 ] |
|
Attempt to fix in pull request #284 |