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

null and {$exists: false} queries inside arrays match less than I'd expect

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 2.2.1
    • Component/s: Querying
    • None
    • Environment:
      Tested with 2.2.1 on MacOS X.
    • ALL

      If I understand properly, the general rule for doing a query

      {'a.x': QUERY}

      where 'a' is an array is that it should match if there is any element of the 'a' array where

      {x: QUERY}

      matches.

      But Mongo 2.2.1 does this:

      > db.x.remove({}); db.x.insert({a: [

      {x: 1}

      , {}]})
      > db.x.findOne({'a.x': {$exists: false}})
      null
      > db.x.findOne(

      {'a.x': null}

      )
      null

      That surprises me: I'd expect both of these to match, because there is an element of the 'a' array (the {}) such that both {x: {$exists: false}} and

      {x: null}

      matches.

      I don't see any relevant tests in the jstests directory asserting that the current behavior is expected. Is this behavior intentional or a bug?

            Assignee:
            aaron Aaron Staple
            Reporter:
            glasser David Glasser
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: