Details
-
Bug
-
Resolution: Unresolved
-
Major - P3
-
None
-
None
-
None
-
None
-
ALL
Description
When inserting a RawBsonDocument that includes duplicated keys, and attempting to exclude said key in a `$project` stage, only the first occurrence of the key is excluded. This appears to be a probable bug.
Tested in the Java driver because the shell doesn't support duplicate keys:
MongoClient client = MongoClients.create("mongodb://mongoUser:hunter1@localhost:37017/?authSource=admin"); |
RawBsonDocument doc = RawBsonDocument.parse("{a: 5, a: 6, a: 7}"); |
|
|
client.getDatabase("keys").getCollection("fts", RawBsonDocument.class).insertOne(doc); |
|
|
var v = client.getDatabase("keys").getCollection("fts", RawBsonDocument.class) |
.aggregate(List.of(new BsonDocument("$project", new BsonDocument("a", new BsonInt64(0))))); |
System.out.println(v.iterator().tryNext());
|
Results in the output:
{"_id": {"$oid": "659daa98f2c70319473b5206"}, "a": 6, "a": 7} |
Or the logically equivalent shell syntax:
keys> db.fts.insert({a: 5, a: 6, a: 7}) # Not supported in shell |
keys> db.fts.aggregate({$project: {a: 0}}) |
[ { _id: ObjectId("659daa98f2c70319473b5206"), a: 6, a: 7 } ] |
Tested in version: 7.2.0-rc1
Tested with non-covered $project