[SERVER-6180] combining field exclusion with operator expression can produce a result with duplicate field names that is incorrect Created: 22/Jun/12  Updated: 13/Jun/15  Resolved: 13/Jun/15

Status: Closed
Project: Core Server
Component/s: Aggregation Framework
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Aaron Staple Assignee: Mathias Stearn
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Operating System: ALL
Participants:

 Description   

Observed behavior: If a field is passed through to a $project result because it is not excluded, and another field with the same name is specified with an operator expression, the result will contain two (duplicate) copies of the original field and value.
Expected behavior: tbd, possibly the operator expression value could override the existing value

Test

c = db.c;
c.drop();
 
c.save( { a:1 } );
 
// Since 'b' is explicitly excluded, the a field is included.  But 'a' is also a computed field.
printjson( c.aggregate( { $project:{ b:0, a:{ $and:[ true ] } } } ) );

Output:

{
	"result" : [
		{
			"_id" : ObjectId("4fe4ec9054a435a9c73cdaa5"),
			"a" : "a",
			"a" : "a"
		}
	],
	"ok" : 1
}



 Comments   
Comment by Mathias Stearn [ 10/Jul/12 ]

SERVER-6361: no exclusion for 2.2

Generated at Thu Feb 08 03:10:58 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.