-
Type:
Question
-
Resolution: Duplicate
-
Priority:
Major - P3
-
None
-
Affects Version/s: None
-
Component/s: mongoimport
-
None
Consider a JSON file with an invalid document:
$ cat b.json {"a":13} {"a":75} {"a":20} {"a":89} {"a":36} {"a":64} {"a":67} {"a":32} {"a":55,} {"a":27}
Note the extra "," in the ninth document. Then try to import it:
$ mongoimport --drop -d test -c foo < b.json 2017-10-11T09:16:29.537-0400 connected to: localhost 2017-10-11T09:16:29.538-0400 dropping: test.foo 2017-10-11T09:16:29.538-0400 Failed: error processing document #9: invalid character '}' looking for beginning of object key string 2017-10-11T09:16:29.538-0400 imported 8 documents
mongoimport reports 8 documents being imported, but there are none in the collection:
$ echo 'db.foo.count()' | mongo MongoDB shell version v3.5.12 connecting to: mongodb://127.0.0.1:27017 MongoDB server version: 3.5.12 0 bye
This is present in master:
$ mongoimport --version mongoimport version: r3.5.12 git version: 3128427f77397916967e3eb684dfed845bb1638a Go version: go1.7 os: darwin arch: amd64 compiler: gc OpenSSL version: OpenSSL 0.9.8zh 14 Jan 2016
Same results (the number of documents reported and inserted differ) using --batchSize 1.
- duplicates
-
TOOLS-1811 mongoimport can report incorrect number inserted if a JSON error occurs.
-
- Closed
-