diff options
author | Kevin Albertson <kevin.albertson@10gen.com> | 2018-01-04 16:27:22 -0500 |
---|---|---|
committer | Kevin Albertson <kevin.albertson@10gen.com> | 2018-01-31 10:25:43 -0500 |
commit | 28c18ba63785d6cbf0ae27c4d5031255b6b79b2c (patch) | |
tree | 135138f6f84a876f55b1c639e8983222d85e0a99 /src/mongo/scripting | |
parent | e8596ec81cd0448310e40d9c2af8f8161dae3965 (diff) | |
download | mongo-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.defs | 1 | ||||
-rw-r--r-- | src/mongo/scripting/mozjs/mongo.cpp | 9 |
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); } |