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

Strange behavior with MinKey comparisons in the shell

    XMLWordPrintableJSON

Details

    • Icon: Bug Bug
    • Resolution: Works as Designed
    • Icon: Major - P3 Major - P3
    • None
    • 3.7.4
    • Shell
    • None
    • Query
    • ALL

    Description

      charlie.swanson discovered the following weird (and seemingly incorrect) behavior with MinKey in the shell:

      > db.foo.insert({x: MinKey})
      WriteResult({ "nInserted" : 1 })
      > db.foo.find()
      { "_id" : ObjectId("5aa9764861da7407ff9101f4"), "x" : { "$minKey" : 1 } }
      > db.foo.findOne()
      { "_id" : ObjectId("5aa9764861da7407ff9101f4"), "x" : { "$minKey" : 1 } }
      > db.foo.findOne().x
      { "$minKey" : 1 }
      > db.foo.findOne().x == MinKey
      true
      > db.foo.findOne({}, {_id: 0}).x == MinKey
      true
      > db.foo.findOne({}, {_id: 0})
      { "x" : { "$minKey" : 1 } }
      > db.foo.findOne({}, {_id: 0}) == {x: MinKey}
      false
      > db.foo.findOne({}, {_id: 0}) == { "x" : { "$minKey" : 1 } }
      false
      

      It seems like there's been weird behavior with this before, in SERVER-8246, but that was such a long time ago it seemed reasonable to open a new ticket.

      Attachments

        Activity

          People

            backlog-server-query Backlog - Query Team (Inactive)
            ian.boros@mongodb.com Ian Boros
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: