diff options
author | Wisdom Omuya <deafgoat@gmail.com> | 2014-12-11 11:57:54 -0500 |
---|---|---|
committer | Wisdom Omuya <deafgoat@gmail.com> | 2014-12-11 11:59:15 -0500 |
commit | 11da80a1369ef4fdc6a0a4dbe2eaaa45eadf8d4b (patch) | |
tree | 750d339c1ba1efc13f6144ca42321a4221eaf374 /mongoimport | |
parent | 6fb18ded19c122aac5c5170300321244cc1fb75f (diff) | |
download | mongo-11da80a1369ef4fdc6a0a4dbe2eaaa45eadf8d4b.tar.gz |
TOOLS-474: --ignoreBlanks is invalid with JSON input type
Former-commit-id: ade9b6fcc37b5566c86232d3622fd3ea395fbf7c
Diffstat (limited to 'mongoimport')
-rw-r--r-- | mongoimport/mongoimport.go | 3 | ||||
-rw-r--r-- | mongoimport/mongoimport_test.go | 7 |
2 files changed, 10 insertions, 0 deletions
diff --git a/mongoimport/mongoimport.go b/mongoimport/mongoimport.go index 1442a981960..c580245b6e6 100644 --- a/mongoimport/mongoimport.go +++ b/mongoimport/mongoimport.go @@ -141,6 +141,9 @@ func (mongoImport *MongoImport) ValidateSettings(args []string) error { if mongoImport.InputOptions.FieldFile != nil { return fmt.Errorf("can not use --fieldFile when input type is JSON") } + if mongoImport.IngestOptions.IgnoreBlanks { + return fmt.Errorf("can not use --ignoreBlanks when input type is JSON") + } } if mongoImport.IngestOptions.UpsertFields != "" { diff --git a/mongoimport/mongoimport_test.go b/mongoimport/mongoimport_test.go index 6eb52c10e48..64a21b00cf4 100644 --- a/mongoimport/mongoimport_test.go +++ b/mongoimport/mongoimport_test.go @@ -157,6 +157,13 @@ func TestMongoImportValidateSettings(t *testing.T) { So(mongoImport.ValidateSettings([]string{}), ShouldNotBeNil) }) + Convey("an error should be thrown if --ignoreBlanks is used with JSON input", func() { + mongoImport, err := NewMongoImport() + So(err, ShouldBeNil) + mongoImport.IngestOptions.IgnoreBlanks = true + So(mongoImport.ValidateSettings([]string{}), ShouldNotBeNil) + }) + Convey("no error should be thrown if --headerline is not supplied "+ "but --fieldFile is supplied", func() { mongoImport, err := NewMongoImport() |