[CSHARP-3146] Unexpected field in deserialization for projection expression with a positional operator Created: 29/Jun/20  Updated: 27/Oct/23  Resolved: 05/Oct/20

Status: Closed
Project: C# Driver
Component/s: Linq, Serialization
Affects Version/s: 2.10.4
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: TimTIM Wong Assignee: Mikalai Mazurenka (Inactive)
Resolution: Gone away Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 Description   

 

var find = collection.Find(x => x.ArrayField.Any(predicate));
 
var a = find.Project<TypeOfX>(
        Builders<TypeOfX>.Projection
            .Include(x => x.ArrayField[-1])
            .Exclude(x => x.Id)
    )
    .FirstOrDefault() // <-- OK
    ?.ArrayField[0];
 
var b = find.Project(x => x.ArrayField[-1])
    .FirstOrDefault(); // <-- MongoInternalException: Unexpected field

Both a and b should be the same, but b throws an exception.
If FirstOrDefault() is replaced with ToString(), both queries are exactly the same. There is a bug in the projection object deserializer.



 Comments   
Comment by Esha Bhargava [ 05/Oct/20 ]

wegylexy@gmail.com There hasn't been any recent activity on this ticket, so we're resolving it. Thanks for reaching out! Please comment on this ticket if you can provide the requested information.

Comment by Mikalai Mazurenka (Inactive) [ 10/Sep/20 ]

wegylexy@gmail.com I cannot reproduce the exception. Could you please provide more details including data, full exception, predicate and the server version?

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