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

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

    XMLWordPrintable

    Details

    • Type: Question
    • Status: Open
    • Priority: Major - P3
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: Backlog
    • Component/s: Shell
    • Labels:
      None

      Description

      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")
      

        Attachments

          Activity

            People

            • Votes:
              0 Vote for this issue
              Watchers:
              7 Start watching this issue

              Dates

              • Created:
                Updated: