return value "n" in db.getLastErrorCmd() have BUG

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Done
    • Priority: Major - P3
    • None
    • Affects Version/s: 2.2.0
    • Component/s: Querying, Write Ops
    • None
    • Environment:
      FreeBSD 7.3-RELEASE FreeBSD 7.3-RELEASE root@:/usr/src/sys/amd64/compile/GENERIC amd64
      db version v2.2.0, pdfile version 4.5
    • FreeBSD
    • Hide

      > db.bobo.save(

      {a:1, b:2, c:3, d:4}

      )
      > db.bobo.find()

      { "_id" : ObjectId("5100b05af1c2c68819360d1a"), "a" : 1, "b" : 2, "c" : 3, "d" : 4 }

      > db.bobo.update(

      {a:1, b:2}

      , {$unset:{c:1, d:1}})
      > db.getLastErrorCmd()
      {
      "n" : 0, // <------- it expected to be `1`
      "lastOp" :

      { "t" : 1358999706000, "i" : 1 }

      ,
      "connectionId" : 131,
      "err" : null,
      "ok" : 1
      }
      > db.bobo.find(

      {a:1, b:2}

      )

      { "_id" : ObjectId("5100b05af1c2c68819360d1a"), "a" : 1, "b" : 2 }

      > db.bobo.update(

      {a:1}

      , {$unset:{b:1}})
      > db.getLastErrorCmd()
      {
      "updatedExisting" : true,
      "n" : 1,
      "lastOp" :

      { "t" : 1358999741000, "i" : 2 }

      ,
      "connectionId" : 131,
      "err" : null,
      "ok" : 1
      }

      Show
      > db.bobo.save( {a:1, b:2, c:3, d:4} ) > db.bobo.find() { "_id" : ObjectId("5100b05af1c2c68819360d1a"), "a" : 1, "b" : 2, "c" : 3, "d" : 4 } > db.bobo.update( {a:1, b:2} , {$unset:{c:1, d:1}}) > db.getLastErrorCmd() { "n" : 0, // <------- it expected to be `1` "lastOp" : { "t" : 1358999706000, "i" : 1 } , "connectionId" : 131, "err" : null, "ok" : 1 } > db.bobo.find( {a:1, b:2} ) { "_id" : ObjectId("5100b05af1c2c68819360d1a"), "a" : 1, "b" : 2 } > db.bobo.update( {a:1} , {$unset:{b:1}}) > db.getLastErrorCmd() { "updatedExisting" : true, "n" : 1, "lastOp" : { "t" : 1358999741000, "i" : 2 } , "connectionId" : 131, "err" : null, "ok" : 1 }
    • None
    • 3
    • None
    • None
    • None
    • None
    • None
    • None

      After updating and unsetting a field, we get result by db.getLastErrorCmd().
      we found strange `n' value returned.
      see below:

            Assignee:
            Ian Daniel (Inactive)
            Reporter:
            HongYing
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: