Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-6180

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

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

      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@mongodb.com Mathias Stearn
            Reporter:
            aaron Aaron Staple
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: