summaryrefslogtreecommitdiff
path: root/src/mongo/scripting
diff options
context:
space:
mode:
authorKevin Albertson <kevin.albertson@10gen.com>2018-01-04 16:27:22 -0500
committerKevin Albertson <kevin.albertson@10gen.com>2018-01-31 10:25:43 -0500
commit28c18ba63785d6cbf0ae27c4d5031255b6b79b2c (patch)
tree135138f6f84a876f55b1c639e8983222d85e0a99 /src/mongo/scripting
parente8596ec81cd0448310e40d9c2af8f8161dae3965 (diff)
downloadmongo-28c18ba63785d6cbf0ae27c4d5031255b6b79b2c.tar.gz
SERVER-32065 support retryWrites URI param in shell
Diffstat (limited to 'src/mongo/scripting')
-rw-r--r--src/mongo/scripting/mozjs/internedstring.defs1
-rw-r--r--src/mongo/scripting/mozjs/mongo.cpp9
2 files changed, 10 insertions, 0 deletions
diff --git a/src/mongo/scripting/mozjs/internedstring.defs b/src/mongo/scripting/mozjs/internedstring.defs
index 3735c576b97..89900e5c35c 100644
--- a/src/mongo/scripting/mozjs/internedstring.defs
+++ b/src/mongo/scripting/mozjs/internedstring.defs
@@ -49,6 +49,7 @@ MONGO_MOZJS_INTERNED_STRING(prototype, "prototype")
MONGO_MOZJS_INTERNED_STRING(_query, "_query")
MONGO_MOZJS_INTERNED_STRING(readOnly, "readOnly")
MONGO_MOZJS_INTERNED_STRING(reason, "reason")
+MONGO_MOZJS_INTERNED_STRING(_retryWrites, "_retryWrites")
MONGO_MOZJS_INTERNED_STRING(_ro, "_ro")
MONGO_MOZJS_INTERNED_STRING(scope, "scope")
MONGO_MOZJS_INTERNED_STRING(servers, "servers")
diff --git a/src/mongo/scripting/mozjs/mongo.cpp b/src/mongo/scripting/mozjs/mongo.cpp
index c28f9e124eb..47bb122cb7f 100644
--- a/src/mongo/scripting/mozjs/mongo.cpp
+++ b/src/mongo/scripting/mozjs/mongo.cpp
@@ -720,6 +720,15 @@ void MongoExternalInfo::construct(JSContext* cx, JS::CallArgs args) {
auto defaultDB = cs.getDatabase() == "" ? "test" : cs.getDatabase();
o.setString(InternedString::defaultDB, defaultDB);
+ // Adds a property to the Mongo connection object.
+ boost::optional<bool> retryWrites = cs.getRetryWrites();
+ // If retryWrites is not explicitly set in uri, sessions created on this connection default to
+ // the global retryWrites value. This is checked in sessions.js by using the injected
+ // _shouldRetryWrites() function, which returns true if the --retryWrites flag was passed.
+ if (retryWrites) {
+ o.setBoolean(InternedString::_retryWrites, retryWrites.get());
+ }
+
args.rval().setObjectOrNull(thisv);
}