Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

SERVER-7660 findAndModify with auth + sort fix

  • Loading branch information...
commit 80aaf5e73a4223b506c1630d6a7f3959acb3d840 1 parent 0027639
@erh erh authored
View
18 jstests/find_and_modify_server7660.js
@@ -0,0 +1,18 @@
+
+t = db.find_and_modify_server7660;
+t.drop();
+
+a = t.findAndModify({
+ query : { foo : 'bar' },
+ update : { $set : { bob : 'john' } },
+ sort: { foo : 1},
+ upsert: true,
+ new : true
+});
+
+b = t.findOne();
+assert.eq( a, b );
+assert.eq( "bar", a.foo );
+assert.eq( "john", a.bob )
+
+
View
6 src/mongo/db/commands/find_and_modify.cpp
@@ -271,7 +271,7 @@ namespace mongo {
uassert(13330, "upsert mode requires query field", !origQuery.isEmpty());
db.update(ns, origQuery, update.embeddedObjectUserCheck(), true);
- BSONObj gle = db.getLastErrorDetailed();
+ BSONObj gle = db.getLastErrorDetailed(dbname);
result.append("lastErrorObject", gle);
if (gle["err"].type() == String) {
errmsg = gle["err"].String();
@@ -293,7 +293,7 @@ namespace mongo {
uassert(12515, "can't remove and update", cmdObj["update"].eoo());
db.remove(ns, QUERY("_id" << out["_id"]), 1);
- BSONObj gle = db.getLastErrorDetailed();
+ BSONObj gle = db.getLastErrorDetailed(dbname);
result.append("lastErrorObject", gle);
if (gle["err"].type() == String) {
errmsg = gle["err"].String();
@@ -325,7 +325,7 @@ namespace mongo {
uassert(12516, "must specify remove or update", !update.eoo());
db.update(ns, q, update.embeddedObjectUserCheck());
- BSONObj gle = db.getLastErrorDetailed();
+ BSONObj gle = db.getLastErrorDetailed(dbname);
result.append("lastErrorObject", gle);
if (gle["err"].type() == String) {
errmsg = gle["err"].String();
Please sign in to comment.
Something went wrong with that request. Please try again.