summaryrefslogtreecommitdiff
path: root/db/dbcommands.cpp
diff options
context:
space:
mode:
authorEliot Horowitz <eliot@10gen.com>2010-10-29 09:49:45 -0400
committerEliot Horowitz <eliot@10gen.com>2010-10-29 09:49:45 -0400
commitdab6e79b37dcdf2d1b58e935370c43e4c91004b4 (patch)
tree907b9c50c138c8b01e8ff88ef306e04387f66521 /db/dbcommands.cpp
parent92d0ac477de0b7fc032d6fa0ec1f88623d44cd1f (diff)
parentfa89431e6c97e88a5adf6d09cfb66394cec4ecb4 (diff)
downloadmongo-dab6e79b37dcdf2d1b58e935370c43e4c91004b4.tar.gz
Merge branch 'master' of github.com:mongodb/mongo
Diffstat (limited to 'db/dbcommands.cpp')
-rw-r--r--db/dbcommands.cpp28
1 files changed, 15 insertions, 13 deletions
diff --git a/db/dbcommands.cpp b/db/dbcommands.cpp
index 41781b9685c..0feccf019c7 100644
--- a/db/dbcommands.cpp
+++ b/db/dbcommands.cpp
@@ -1359,24 +1359,26 @@ namespace mongo {
} else {
- Query idQuery = QUERY( "_id" << out["_id"]);
-
if (cmdObj["remove"].trueValue()){
uassert(12515, "can't remove and update", cmdObj["update"].eoo());
- db.remove(ns, idQuery, 1);
+ db.remove(ns, QUERY("_id" << out["_id"]), 1);
} else { // update
- // need to include original query for $ positional operator
- BSONObjBuilder b;
- b.append(out["_id"]);
- BSONObjIterator it(origQuery);
- while (it.more()){
- BSONElement e = it.next();
- if (strcmp(e.fieldName(), "_id"))
- b.append(e);
+ BSONElement queryId = origQuery["_id"];
+ if (queryId.eoo() || getGtLtOp(queryId) != BSONObj::Equality){
+ // need to include original query for $ positional operator
+
+ BSONObjBuilder b;
+ b.append(out["_id"]);
+ BSONObjIterator it(origQuery);
+ while (it.more()){
+ BSONElement e = it.next();
+ if (strcmp(e.fieldName(), "_id"))
+ b.append(e);
+ }
+ q = Query(b.obj());
}
- q = Query(b.obj());
BSONElement update = cmdObj["update"];
uassert(12516, "must specify remove or update", !update.eoo());
@@ -1389,7 +1391,7 @@ namespace mongo {
}
if (cmdObj["new"].trueValue())
- out = db.findOne(ns, idQuery, fields);
+ out = db.findOne(ns, QUERY("_id" << out["_id"]), fields);
}
}