$exist: false check failed for nested document

XMLWordPrintableJSON

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

      Document:

      db.testStat.insert({_id: ObjectId("5426a05d9fc673d74e4ed001"), msn: []});
      db.testStat.update({_id: ObjectId("5426a05d9fc673d74e4ed001")}, {$push: { msn:
      {$each: [
          {
              "mid": ObjectId("5426a05d9fc673d74e4ed101"),
              "tasks": [
                  {"tid": ObjectId("5426a05d9fc673d74e4ed301"), "cptd": 1411817713000},
                  {"tid": ObjectId("5426a05d9fc673d74e4ed302")},
                  {"tid": ObjectId("5426a05d9fc673d74e4ed303"), "cptd": 1411817713000},
                  {"tid": ObjectId("5426a05d9fc673d74e4ed304")}
              ]
          },
          {
              "mid": ObjectId("5426a05d9fc673d74e4ed102"),
              "tasks": [
                  {"tid": ObjectId("5426a05d9fc673d74e4ed305"), "cptd": 1411817713000},
                  {"tid": ObjectId("5426a05d9fc673d74e4ed306")},
                  {"tid": ObjectId("5426a05d9fc673d74e4ed307"), "cptd": 1411817713000},
                  {"tid": ObjectId("5426a05d9fc673d74e4ed308")}
              ],
              "cptd": 1411817713000
          }
      
      ]}
      }});
      

      Query:

      db.testStat.find({"msn.cptd": {$exists: false}})
      

      Workaround:

      db.testStat.find({"msn.cptd": {$gt: 0}})
      
      Show
      Document: db.testStat.insert({_id: ObjectId( "5426a05d9fc673d74e4ed001" ), msn: []}); db.testStat.update({_id: ObjectId( "5426a05d9fc673d74e4ed001" )}, {$push: { msn: {$each: [ { "mid" : ObjectId( "5426a05d9fc673d74e4ed101" ), "tasks" : [ { "tid" : ObjectId( "5426a05d9fc673d74e4ed301" ), "cptd" : 1411817713000}, { "tid" : ObjectId( "5426a05d9fc673d74e4ed302" )}, { "tid" : ObjectId( "5426a05d9fc673d74e4ed303" ), "cptd" : 1411817713000}, { "tid" : ObjectId( "5426a05d9fc673d74e4ed304" )} ] }, { "mid" : ObjectId( "5426a05d9fc673d74e4ed102" ), "tasks" : [ { "tid" : ObjectId( "5426a05d9fc673d74e4ed305" ), "cptd" : 1411817713000}, { "tid" : ObjectId( "5426a05d9fc673d74e4ed306" )}, { "tid" : ObjectId( "5426a05d9fc673d74e4ed307" ), "cptd" : 1411817713000}, { "tid" : ObjectId( "5426a05d9fc673d74e4ed308" )} ], "cptd" : 1411817713000 } ]} }}); Query: db.testStat.find({ "msn.cptd" : {$exists: false }}) Workaround: db.testStat.find({ "msn.cptd" : {$gt: 0}})
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      > db.version()
      2.6.4

      $exist: false check for nested document field is worked inproper (according to documentation).
      Was anticipating document that does not contain this fiend in embedded document.
      $exist: true returns expected result.

            Assignee:
            Unassigned
            Reporter:
            Senz
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: