-
Type: New Feature
-
Resolution: Fixed
-
Priority: Unknown
-
Affects Version/s: None
-
Component/s: None
-
None
-
Not Needed
-
Summary
Projection on document ID alone creates invalid projection.
C# Driver Version: 2.19.1, 2.19.2
MongoDB Version: 4.0, 4.2
MongoDB Topology: Using the Mongo driver for Azure; sharded cluster I think?
How to Reproduce
Attached is a small console application to demonstrate the error. I tested with both a string ID and an ObjectId ID, but both fail: strings are null, ObjectIDs are empty.
The projection is pretty simple, in the test case, it's just:
collection.Find(_ => true).Project(x => x.Id)
(Finding all documents just for the small test I have.)
However, the projection it generates in v2.19+ is:
find({ }, { "_v" : "$_id", "_id" : 0 })
In prior versions (we were using 2.14), this code worked, and the generated projection is what I'd have expected:
find({ }, { "_id" : 1 })
- is duplicated by
-
CSHARP-4727 IFindFluent.Project on a single field always returns null
- Closed