summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authormike o'brien <mpobrien005@gmail.com>2014-09-26 16:00:52 -0400
committermike o'brien <mpobrien005@gmail.com>2014-09-26 16:00:52 -0400
commit1d370672f544e83efd1f0556dcae7d026d6c5ae8 (patch)
tree32a115c820d6c68cf723acdaf0dbc78510a5827e /src
parent37f304a25127d22f0514801f6170d447d83e6846 (diff)
downloadmongo-1d370672f544e83efd1f0556dcae7d026d6c5ae8.tar.gz
fix dumprestore4.js: return a failure code if --collection specified without --db
Former-commit-id: 5a21240a925ca7d12b3cd5976e97fc283362b9ac
Diffstat (limited to 'src')
-rw-r--r--src/github.com/mongodb/mongo-tools/mongorestore/mongorestore.go4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/github.com/mongodb/mongo-tools/mongorestore/mongorestore.go b/src/github.com/mongodb/mongo-tools/mongorestore/mongorestore.go
index c1177e08dd9..617eac69f68 100644
--- a/src/github.com/mongodb/mongo-tools/mongorestore/mongorestore.go
+++ b/src/github.com/mongodb/mongo-tools/mongorestore/mongorestore.go
@@ -54,6 +54,10 @@ func (restore *MongoRestore) ParseAndValidateOptions() error {
log.Log(3, "\tdumping with object check enabled")
}
+ if restore.ToolOptions.DB == "" && restore.ToolOptions.Collection != "" {
+ return fmt.Errorf("cannot dump a collection without a specified database")
+ }
+
if restore.OutputOptions.WriteConcern > 0 {
restore.safety = &mgo.Safe{W: restore.OutputOptions.WriteConcern} //TODO, audit extra steps
log.Logf(3, "\tdumping with w=%v", restore.safety.W)