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

$bit update modifier doesn't work when field does not exist

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Fixed
    • Affects Version/s: 1.8.1
    • Fix Version/s: 2.5.3
    • Component/s: Write Ops
    • Labels:
      None
    • Operating System:
      ALL

      Description

      The $bit update modifier doesn't work when field does not exist. In this case it also causes other update modifiers to be ignored. To be consistent with other modifieds (like $inc) it should probably treat a nonexistent field as an implied zero.

      To reproduce:

      > // $bit or should work if field doesn't exist:
      > db.test.insert(

      {x:1}

      )
      > db.test.find()

      { "_id" : ObjectId("4dc29da73691b2a95024293b"), "x" : 1 }

      > db.test.update({}, { $bit : { or :

      { y : 2 }

      }}) // y does not exist
      > db.test.find()

      { "_id" : ObjectId("4dc29da73691b2a95024293b"), "x" : 1 }

      >
      > // $bit with field that doesn't exist causes other modifiers to be ignored
      > db.test.update({}, { $set :

      { x : 2 }

      , $bit : { or :

      { y : 2 }

      }}) // y does not exist
      > db.test.find()

      { "_id" : ObjectId("4dc29da73691b2a95024293b"), "x" : 1 }

      >
      > // $bit with field that doesn't exist causes other modifiers to be ignored
      > db.test.update({}, { $set :

      { x : 2 }

      , $bit : { and :

      { y : 2 }

      }}) // y does not exist, $set of x is ignored
      > db.test.find()

      { "_id" : ObjectId("4dc29da73691b2a95024293b"), "x" : 1 }

      >

        Attachments

          Issue Links

            Activity

              People

              • Votes:
                4 Vote for this issue
                Watchers:
                6 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: