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

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

    • Type: Icon: Improvement Improvement
    • Resolution: Unresolved
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: Query Language
    • Query Optimization

      > 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.

            Assignee:
            backlog-query-optimization [DO NOT USE] Backlog - Query Optimization
            Reporter:
            mathias@mongodb.com Mathias Stearn
            Votes:
            0 Vote for this issue
            Watchers:
            11 Start watching this issue

              Created:
              Updated: