Empty parent returned where projection key doesn't exist

XMLWordPrintableJSON

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

      // Returns immediate parent which exists
      db.test.insert({'level1':{'level2':

      {'key':'value'}

      }})
      db.test.find({},

      {'level1.level2.key2':1,'_id':0}

      )
      Result: { "level1" : { "level2" : { } } }
      Expected: Nothing

      // Returns 2 parents up which exists
      db.test.insert({'level1':{'key':'value'}})
      db.test.find({},

      {'level1.level2.key2':1,'_id':0}

      )
      Result: { "level1" : { } }
      Expected: Nothing

      It should be noted that if there was a projection for keys within the respective docs returned they would be showed. However, I'm not sure why an empty sub doc is returned when no other projections are made for it.

      Is this an intended design or a bug?

      Show
      // Returns immediate parent which exists db.test.insert({'level1':{'level2': {'key':'value'} }}) db.test.find({}, {'level1.level2.key2':1,'_id':0} ) Result: { "level1" : { "level2" : { } } } Expected: Nothing // Returns 2 parents up which exists db.test.insert({'level1':{'key':'value'}}) db.test.find({}, {'level1.level2.key2':1,'_id':0} ) Result: { "level1" : { } } Expected: Nothing It should be noted that if there was a projection for keys within the respective docs returned they would be showed. However, I'm not sure why an empty sub doc is returned when no other projections are made for it. Is this an intended design or a bug?
    • None
    • 3
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      When using dot notation to construct a projection on sub document keys, if the key specified in the project doesn't exist it returns the next ancestor which does exist, but as an empty document.

              Assignee:
              Stennie Steneker (Inactive)
              Reporter:
              Matt Campbell
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Created:
                Updated:
                Resolved: