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

$lookup doesn't match an array with object that misses the local key to null

    • Type: Icon: Bug Bug
    • Resolution: Won't Fix
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • ALL

      db.l.find()
      { "_id" : 1, "a" : { "no_x" : 1 } }
      { "_id" : 2, "a" : [ { "no_x" : 1 }, { "no_x" : 2 } ] }
      { "_id" : 3, "a" : [ { "x" : 1 }, { "no_x" : 2 } ] }
      { "_id" : 4, "a" : [ { "x" : 1 }, { "x" : null } ] }
      
      db.r.find()
      { "_id" : 0, "b" : null }
      
      db.l.find({"a.x":null})
      { "_id" : 1, "a" : { "no_x" : 1 } }
      { "_id" : 2, "a" : [ { "no_x" : 1 }, { "no_x" : 2 } ] }
      { "_id" : 3, "a" : [ { "x" : 1 }, { "no_x" : 2 } ] }
      { "_id" : 4, "a" : [ { "x" : 1 }, { "x" : null } ] }
      // All four records match to 'null'.
      
      db.l.aggregate({$lookup: {from:"r", localField:"a.x", foreignField:"b", as:"matched"}})
      { "_id" : 1, "a" : { "no_x" : 1 }, "matched" : [ { "_id" : 0, "b" : null } ] }
      { "_id" : 2, "a" : [ { "no_x" : 1 }, { "no_x" : 2 } ], "matched" : [ { "_id" : 0, "b" : null } ] }
      { "_id" : 3, "a" : [ { "x" : 1 }, { "no_x" : 2 } ], "matched" : [ ] } // didn't match to 'null'
      { "_id" : 4, "a" : [ { "x" : 1 }, { "x" : null } ], "matched" : [ { "_id" : 0, "b" : null } ] }
      

            Assignee:
            christopher.harris@mongodb.com Chris Harris
            Reporter:
            irina.yatsenko@mongodb.com Irina Yatsenko (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            8 Start watching this issue

              Created:
              Updated:
              Resolved: