combining field exclusion with operator expression can produce a result with duplicate field names that is incorrect

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Done
    • Priority: Major - P3
    • None
    • Affects Version/s: None
    • Component/s: Aggregation Framework
    • None
    • ALL
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      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
      }
      

            Assignee:
            Mathias Stearn
            Reporter:
            Aaron Staple (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: