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

Compare Date vs timestamp errors out, timestamp vs Date doesn't

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Duplicate
    • Affects Version/s: 2.2.2, 2.3.2
    • Fix Version/s: None
    • Component/s: Querying
    • Labels:
    • Operating System:
      ALL
    • Steps To Reproduce:
      Hide

      > db.a.drop()
      > db.a.insert({d:new Date(), ts: new Timestamp()})
      > db.a.find({ts:Date()})
      > db.a.find({d:Timestamp()})
      error: { "$err" : "wrong type for field (d) 17 != 9", "code" : 13111 }

      Show
      > db.a.drop() > db.a.insert({d: new Date(), ts: new Timestamp()}) > db.a.find({ts:Date()}) > db.a.find({d:Timestamp()}) error: { "$err" : "wrong type for field (d) 17 != 9" , "code" : 13111 }

      Description

      Comparing Date to timestamp causes an error to appear in the shell, comparing timestamp to date does not. Also the error is not very descriptive in the shell.

      > db.a.drop()
      > db.a.insert({d:new Date(), ts: new Timestamp()})
      > db.a.find({ts:Date()})
      > db.a.find({d:Timestamp()})
      error: { "$err" : "wrong type for field (d) 17 != 9", "code" : 13111 }

      Sorting on such a collection is also broken:

      > db.a.drop()
      > db.a.insert({a:Timestamp()})
      > db.a.insert({a:ISODate()})
      > db.a.find().sort({a:1})
      error: { "$err" : "wrong type for field () 17 != 9", "code" : 13111 }

        Attachments

          Issue Links

            Activity

              People

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

                Dates

                • Created:
                  Updated:
                  Resolved: