[SERVER-3046] $bit update modifier doesn't work when field does not exist Created: 05/May/11 Updated: 12/Jul/16 Resolved: 20/Nov/13 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | Write Ops |
| Affects Version/s: | 1.8.1 |
| Fix Version/s: | 2.5.3 |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | Robert Stam | Assignee: | David Storch |
| Resolution: | Done | Votes: | 4 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||
| Operating System: | ALL | ||||||||
| Participants: | |||||||||
| 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.update({}, { $bit : { or : { y : 2 }}}) // y does not exist > , $bit : { or : { y : 2 }}}) // y does not exist > , $bit : { and : { y : 2 }}}) // y does not exist, $set of x is ignored > |
| Comments |
| Comment by James Hartig [ 14/Mar/14 ] |
|
Any chance of backporting this to 2.4 or 2.2? There isn't really a workaround for this without doing a lookup first. |
| Comment by Scott Hernandez (Inactive) [ 20/Nov/13 ] |
|
Looks like there is already a test here https://github.com/mongodb/mongo/blob/master/jstests/verify_update_mods.js#L55 |
| Comment by David Storch [ 20/Nov/13 ] |
|
This is fixed in 2.5.3. I will add a js test before resolving. |