$project of nested projection regression 3.2 -> 3.4

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Duplicate
    • Priority: Minor - P4
    • None
    • Affects Version/s: 3.4.9
    • Component/s: Aggregation Framework
    • None
    • Environment:
      Linux and OS X
    • ALL
    • Hide

      Given this aggregation:

      db.inventory.drop()
      db.inventory.insertOne( { item: 1, qty:{ sold: 1 } });
      db.inventory.insertOne( { item: 3, qty:{ etc: 3 } });
      db.inventory.insertOne( { item: 4, });
      
      var pipeline = [{ $project : {"_id" : 0, "0" : { "sold" : "$qty.sold"} } }];
      var result = db.inventory.aggregate(pipeline);
      
      result.forEach(function(r) { printjson(r) } )
      

      If you run the above aggregation against 3.2.* this is the result:

      { "0" : { "sold" : 1 } }
      { }
      { }
      

      If you run the above aggregation against 3.4.* this is the result:

      { "0" : { "sold" : 1 } }
      { "0" : { } }
      { "0" : { } }
      
      Show
      Given this aggregation: db.inventory.drop() db.inventory.insertOne( { item: 1, qty:{ sold: 1 } }); db.inventory.insertOne( { item: 3, qty:{ etc: 3 } }); db.inventory.insertOne( { item: 4, }); var pipeline = [{ $project : { "_id" : 0, "0" : { "sold" : "$qty.sold" } } }]; var result = db.inventory.aggregate(pipeline); result.forEach( function (r) { printjson(r) } ) If you run the above aggregation against 3.2.* this is the result: { "0" : { "sold" : 1 } } { } { } If you run the above aggregation against 3.4.* this is the result: { "0" : { "sold" : 1 } } { "0" : { } } { "0" : { } }
    • Query 2017-10-23
    • None
    • 3
    • None
    • None
    • None
    • None
    • None
    • None

      The result of a projection using nested keys is different from 3.2 to 3.4.

      We had to use `$ifnull` in some cases to avoid this difference of results.

      I couldn't find any breaking change listed on 3.4 mentioning this change and I couldn't find any issue that was describing exactly this issue.

      We found this after changing our CI to use 3.4

      I'm sorry if I missed some documentation explaining this breaking change. Thanks for your attention!

            Assignee:
            Charlie Swanson
            Reporter:
            Eduardo Gurgel Pinho
            Votes:
            1 Vote for this issue
            Watchers:
            8 Start watching this issue

              Created:
              Updated:
              Resolved: