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(
)
> db.test.find()
> db.test.update({}, { $bit : { or :
{ y : 2 }}}) // y does not exist
> db.test.find()
>
> // $bit with field that doesn't exist causes other modifiers to be ignored
> db.test.update({}, { $set :
, $bit : { or :
{ y : 2 }}}) // y does not exist
> db.test.find()
>
> // $bit with field that doesn't exist causes other modifiers to be ignored
> db.test.update({}, { $set :
, $bit : { and :
{ y : 2 }}}) // y does not exist, $set of x is ignored
> db.test.find()
>
- is related to
-
SERVER-3223 $bit won't do an upsert
- Closed