-
Type: Bug
-
Resolution: Duplicate
-
Priority: Major - P3
-
None
-
Affects Version/s: 1.8.1, 1.9.0
-
Component/s: None
-
None
-
Environment:Reproduced in Win32 and Linux x86_64 but likely all.
-
ALL
Repro steps in the mongo shell:
> use benchmark
switched to db benchmark
> col = db.scoreboard
benchmark.scoreboard
> col.ensureIndex(
)
> col.ensureIndex(
)
> col.insert(
)
> db.runCommand({'findAndModify': 'scoreboard', 'query': {'user': 'bob', 'score': {'$lt': 10}}, 'update': {'$set': {'score': 10}}, 'upsert': true, 'fields': {'_id': false, 'score': true}})
{
"errmsg" : "exception: assertion db/../bson/bsonobjbuilder.h:115",
"code" : 0,
"ok" : 0
}
If you don't include '_id' in fields or set it to true there is no issue:
> db.runCommand({'findAndModify': 'scoreboard', 'query': {'user': 'bob', 'score': {'$lt': 10}}, 'update': {'$set': {'score': 10}}, 'upsert': true, 'fields': {'score': true}})
{
"lastErrorObject" :
,
"value" :
,
"ok" : 1
}
> db.runCommand({'findAndModify': 'scoreboard', 'query': {'user': 'bob', 'score': {'$lt': 10}}, 'update': {'$set': {'score': 10}}, 'upsert': true, 'fields': {'_id': true, 'score': true}})
{
"lastErrorObject" :
,
"value" : {
},
"ok" : 1
- duplicates
-
SERVER-2626 Excluding _id field doesn't work with FindAndModify
- Closed