-
Type: Bug
-
Resolution: Duplicate
-
Priority: Major - P3
-
None
-
Affects Version/s: 3.0.8, 3.2.9, 3.3.12
-
Component/s: mongoexport, mongoimport
-
None
The examples try to roundtrip a document with multiple date fields. Attached is a dump of the test.date collection since minDate and maxDate cannot be created in the mongo shell.
$ ~/Downloads/mongodb-osx-x86_64-enterprise-3.2.9/bin/mongorestore --dir ~/Downloads/dump 2016-08-31T10:59:55.405-0700 building a list of dbs and collections to restore from /Users/shane/Downloads/dump dir 2016-08-31T10:59:55.405-0700 reading metadata for test.date from /Users/shane/Downloads/dump/test/date.metadata.json 2016-08-31T10:59:55.452-0700 restoring test.date from /Users/shane/Downloads/dump/test/date.bson 2016-08-31T10:59:55.454-0700 restoring indexes for collection test.date from metadata 2016-08-31T10:59:55.454-0700 finished restoring test.date (1 document) 2016-08-31T10:59:55.454-0700 done $ mongo --eval "db.date.findOne();" MongoDB shell version: 3.2.8 connecting to: test { "_id" : ObjectId("573debafd3a32e75b0d56bf1"), "maxDate" : ISODate("292278994-08-17T07:12:56.808Z"), "minDate" : ISODate("-292275055-05-16T16:47:02.192Z"), "largeDate" : ISODate("2038-01-19T03:14:08Z"), "smallDate" : ISODate("1901-12-13T20:45:52Z") }
Roundtripping using mongoexport/mongoimport 2.6 only maxDate is preserved:
$ ~/Downloads/mongodb-osx-x86_64-ssl-2.6.4-splunk/bin/mongoexport -d test -c date --out date26.json connected to: 127.0.0.1 exported 1 records $ cat date26.json { "_id" : { "$oid" : "573debafd3a32e75b0d56bf1" }, "maxDate" : { "$date" : { "$numberLong" : "9223372036854775807" } }, "minDate" : { "$date" : { "$numberLong" : "-9223372036854775808" } }, "largeDate" : { "$date" : "2038-01-18T19:14:08.000-0800" }, "smallDate" : { "$date" : { "$numberLong" : "-2147483648000" } } } $ ~/Downloads/mongodb-osx-x86_64-ssl-2.6.4-splunk/bin/mongoimport -d test -c date26 date26.json connected to: 127.0.0.1 2016-08-31T11:11:29.319-0700 imported 1 objects $ mongo --eval "db.date26.findOne();" MongoDB shell version: 3.2.8 connecting to: test { "_id" : ObjectId("573debafd3a32e75b0d56bf1"), "maxDate" : ISODate("292278994-08-17T07:12:56.808Z") }
Roundtripping using mongoexport/mongoimport 3.0, 3.2, and 3.3 cause parse errors:
$ ~/Downloads/mongodb-osx-x86_64-ssl-3.0.8-splunk/bin/mongoexport -d test -c date --out date30.json 2016-08-31T11:12:32.217-0700 connected to: localhost 2016-08-31T11:12:32.217-0700 exported 1 record $ cat date30.json {"_id":{"$oid":"573debafd3a32e75b0d56bf1"},"maxDate":{"$date":{"$numberLong":"9223372036854775807"}},"minDate":{"$date":"-292275055-05-16T16:47:04.192Z"},"largeDate":{"$date":"2038-01-19T03:14:08.000Z"},"smallDate":{"$date":"1901-12-13T20:45:52.000Z"}} $ ~/Downloads/mongodb-osx-x86_64-ssl-3.0.8-splunk/bin/mongoimport -d test -c date30 date30.json 2016-08-31T11:12:54.830-0700 connected to: localhost 2016-08-31T11:12:54.830-0700 Failed: error getting extended BSON for document #0: parsing time "-292275055-05-16T16:47:04.192Z" as "2006-01-02T15:04:05Z07:00": cannot parse "-292275055-05-16T16:47:04.192Z" as "2006" 2016-08-31T11:12:54.830-0700 imported 0 documents $ ~/Downloads/mongodb-osx-x86_64-enterprise-3.2.9/bin/mongoexport -d test -c date --out date32.json 2016-08-31T11:14:00.386-0700 connected to: localhost 2016-08-31T11:14:00.386-0700 exported 1 record $ cat date32.json {"_id":{"$oid":"573debafd3a32e75b0d56bf1"},"maxDate":{"$date":{"$numberLong":"9223372036854775807"}},"minDate":{"$date":"-292275055-05-16T16:47:04.192Z"},"largeDate":{"$date":"2038-01-19T03:14:08.000Z"},"smallDate":{"$date":"1901-12-13T20:45:52.000Z"}} $ ~/Downloads/mongodb-osx-x86_64-enterprise-3.2.9/bin/mongoimport -d test -c date32 date32.json 2016-08-31T11:14:35.914-0700 connected to: localhost 2016-08-31T11:14:35.915-0700 Failed: error getting extended BSON for document #0: parsing time "-292275055-05-16T16:47:04.192Z" as "2006-01-02T15:04:05Z07:00": cannot parse "-292275055-05-16T16:47:04.192Z" as "2006" 2016-08-31T11:14:35.915-0700 imported 0 documents $ ~/Downloads/mongodb-osx-x86_64-enterprise-3.3.12/bin/mongoexport -d test -c date --out date33.json 2016-08-31T12:02:41.208-0700 connected to: localhost 2016-08-31T12:02:41.209-0700 exported 1 record $ cat date33.json {"_id":{"$oid":"573debafd3a32e75b0d56bf1"},"maxDate":{"$date":{"$numberLong":"9223372036854775807"}},"minDate":{"$date":"-292275055-05-16T16:47:04.192Z"},"largeDate":{"$date":"2038-01-19T03:14:08.000Z"},"smallDate":{"$date":"1901-12-13T20:45:52.000Z"}} $ ~/Downloads/mongodb-osx-x86_64-enterprise-3.3.12/bin/mongoimport -d test -c date33 date33.json 2016-08-31T12:03:27.151-0700 connected to: localhost 2016-08-31T12:03:27.152-0700 Failed: error getting extended BSON for document #0: parsing time "-292275055-05-16T16:47:04.192Z" as "2006-01-02T15:04:05Z07:00": cannot parse "-292275055-05-16T16:47:04.192Z" as "2006" 2016-08-31T12:03:27.152-0700 imported 0 documents
- duplicates
-
TOOLS-1610 implement the extended json spec in import/export
- Closed
- related to
-
SERVER-15275 Datetimes before the epoch are exported as $numberLong
- Closed
-
TOOLS-1179 The maximum date value exports using a long rather than an ISO-8601 formatted string
- Closed