Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-40739

Why does min Date get converted to unix epoch on insert?

    • Type: Icon: Question Question
    • Resolution: Won't Do
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: Shell
    • Server Development Platform
    • Dev Tools 2019-05-20, Dev Tools 2019-06-03

      Semi-related to SERVER-40737, when inserting the min Date, Date(NumberLong("-9223372036854775808"), from the mongo shell it gets converted into ISODate("1970-01-01T00:00:00Z"). Is this intentional? I would expect it to error instead of silently converting the date.

      MongoDB shell version v4.1.10-150-g8560239dba
      connecting to: mongodb://127.0.0.1:27017/?compressors=disabled&gssapiServiceName=mongodb
      Implicit session: session { "id" : UUID("5222ca7a-9585-45c2-a322-a8abe6b72791") }
      MongoDB server version: 4.1.10-150-g8560239dba
      PRIMARY> db.test.insertOne({date: new Date(NumberLong("-9223372036854775808"))})
      {
      	"acknowledged" : true,
      	"insertedId" : ObjectId("5cba186bc1feb27106e4c8b5")
      }
      PRIMARY> db.test.find()
      { "_id" : ObjectId("5cba186bc1feb27106e4c8b5"), "date" : ISODate("1970-01-01T00:00:00Z") }
      PRIMARY> new Date(NumberLong("-9223372036854775808"))
      ISODate("0NaN-NaN-NaNTNaN:NaN:NaNZ")
      

            Assignee:
            backlog-server-devplatform [DO NOT ASSIGN] Backlog - Server Development Platform Team (SDP) (Inactive)
            Reporter:
            shane.harvey@mongodb.com Shane Harvey
            Votes:
            0 Vote for this issue
            Watchers:
            8 Start watching this issue

              Created:
              Updated:
              Resolved: