diff options
author | Shaun Verch <shaun.verch@10gen.com> | 2013-04-25 15:03:59 -0700 |
---|---|---|
committer | Dan Pasette <dan@10gen.com> | 2013-05-17 16:24:32 -0700 |
commit | 7d43e2ded4c1b2e62349263d1e6a800f5f0eee75 (patch) | |
tree | 6e8371b32d5d7d986663a5582185443ca9631182 | |
parent | 67fc55fbf944341c4662850d2d165e16114f47ea (diff) | |
download | mongo-7d43e2ded4c1b2e62349263d1e6a800f5f0eee75.tar.gz |
SERVER-8066 (2/2) Skip undefined fields in mongorestore
-rw-r--r-- | src/mongo/tools/restore.cpp | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/src/mongo/tools/restore.cpp b/src/mongo/tools/restore.cpp index 9180005fe56..abd7f868afe 100644 --- a/src/mongo/tools/restore.cpp +++ b/src/mongo/tools/restore.cpp @@ -485,7 +485,11 @@ private: } void createCollectionWithOptions(BSONObj cmdObj) { + + // Create a new cmdObj to skip undefined fields and fix collection name BSONObjBuilder bo; + + // Add a "create" field if it doesn't exist if (!cmdObj.hasField("create")) { bo.append("create", _curcoll); } @@ -493,11 +497,18 @@ private: BSONObjIterator i(cmdObj); while ( i.more() ) { BSONElement e = i.next(); + + // Replace the "create" field with the name of the collection we are actually creating if (strcmp(e.fieldName(), "create") == 0) { bo.append("create", _curcoll); } else { - bo.append(e); + if (e.type() == Undefined) { + log() << _curns << ": skipping undefined field: " << e.fieldName() << endl; + } + else { + bo.append(e); + } } } cmdObj = bo.obj(); |