[CSHARP-365] Explain doesn't send Fields to the server resulting in indexOnly value sometimes being incorrect Created: 15/Dec/11  Updated: 02/Apr/15  Resolved: 16/Dec/11

Status: Closed
Project: C# Driver
Component/s: None
Affects Version/s: 1.3.1
Fix Version/s: 1.4

Type: Bug Priority: Minor - P4
Reporter: Robert Stam Assignee: Robert Stam
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 Description   

The Explain method in the C# driver doesn't pass the Fields value to the server resulting in the indexOnly value sometimes being incorrect.

To reproduce:

collection.Drop();
collection.EnsureIndex("A", "_id");
collection.Insert(new BsonDocument { { "_id", 1 }, { "A", 1 } });
collection.Insert(new BsonDocument { { "_id", 2 }, { "A", 2 } });
collection.Insert(new BsonDocument { { "_id", 3 }, { "A", 3 } });
 
var query = Query.EQ("A", 1);
var fields = Fields.Include("_id");
var cursor = collection.Find(query).SetFields(fields);
var explain = cursor.Explain();
Console.WriteLine(explain.ToJson());



 Comments   
Comment by Robert Stam [ 16/Dec/11 ]

Fixed. Explain clones the cursor in order to leave the original cursor unchanged, and the cloning was not including the fields specifier.

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