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

Parsing {$ne: X} to {$not: {$eq: X}} is weird with arrays

    XMLWordPrintableJSON

Details

    • Icon: Improvement Improvement
    • Resolution: Unresolved
    • Icon: Major - P3 Major - P3
    • None
    • None
    • Query Language
    • Query Optimization

    Description

      > db.blah.insert({a: 'not 3'})
      WriteResult({ "nInserted" : 1 })
      > db.blah.insert({a: ['not 3', 3]})
      WriteResult({ "nInserted" : 1 })
      > db.blah.find({a: {$ne: 3}})
      { "_id" : ObjectId("60634e127cc9a947848c101a"), "a" : "not 3" }
      

      Under the normal rules for arrays, both documents should match, since they each have at least one element in a that matches. However because we convert
      {a: {$ne: X
      }} to {$not: {a: {$eq: X}}} at parse time, we get the observed semantics. If people actually want that behavior, they could always type that directly.

      Might not be able to fix this in MQL1.0, but probably worth keeping this in a list of things to fix for MQL2.0.

      Attachments

        Activity

          People

            backlog-query-optimization Backlog - Query Optimization
            mathias@mongodb.com Mathias Stearn
            Votes:
            0 Vote for this issue
            Watchers:
            11 Start watching this issue

            Dates

              Created:
              Updated: