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

XMLWordPrintableJSON

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

      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 Staple (Inactive)
            Reporter:
            David Glasser
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: