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

$exist: false check failed for nested document

    XMLWordPrintableJSON

Details

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Major - P3 Major - P3
    • None
    • 2.6.4
    • 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}})

    Description

      > 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.

      Attachments

        Activity

          People

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

            Dates

              Created:
              Updated:
              Resolved: