Details
-
Bug
-
Resolution: Won't Fix
-
Minor - P4
-
None
-
None
-
None
Description
When the following code is executed against a version of the database earlier than 3.2 where a CommandListener has been configured, the filter criteria is omitted from the CommandStartedEvent when a $comment has been manually added to the query:
MongoClient mongoClient = new MongoClient("localhost", options);
|
MongoDatabase test = mongoClient.getDatabase("test");
|
MongoCollection<Document> coll = test.getCollection("TestCollection");
|
|
|
coll.insertOne(new Document("a", 1));
|
coll.find(new Document("a", 1)).modifiers(new Document("$comment", "test")).first();
|
coll.find(new Document("a", 1).append("$comment", "test")).first();
|
Against 3.2, the following output is seen:
{ "insert" : "TestCollection", "ordered" : true, "documents" : [{ "_id" : { "$oid" : "57594e2ce97b981da4837eb1" }, "a" : 1 }] }
|
{ "find" : "TestCollection", "comment" : "test", "filter" : { "a" : 1 }, "limit" : 1, "singleBatch" : true }
|
{ "find" : "TestCollection", "filter" : { "a" : 1, "$comment" : "test" }, "limit" : 1, "singleBatch" : true }
|
Against 2.6 or 3.0, the output is:
{ "insert" : "TestCollection", "ordered" : true, "documents" : [{ "_id" : { "$oid" : "57595531e97b981dd04c719b" }, "a" : 1 }] }
|
{ "find" : "TestCollection", "comment" : "test", "filter" : { "a" : 1 }, "limit" : -1 }
|
{ "find" : "TestCollection", "comment" : "test", "limit" : -1 }
|
A source file is attached which when compiled reliable reproduces the issue.
This was tested against version 3.2.2 of the driver.