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

$all with empty operand never matches any documents

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

      The documentation for $all says:

       

      The $all operator selects the documents where the value of a field is an array that contains all the specified elements. 

      In the case of find({foo: {$all: []}}), there are no specified elements, which means that by this definition should match all documents where foo is an array (see SERVER-99070 for cases where the array clause is misleading). However, the current implementation will parse this query as $alwaysFalse.

       

      To improve the situation, the implementation should either:

      1. Parse to $alwaysTrue and update the docs to remove the array clause
      2. Match all documents where foo is an array
      3. Become a parse-time error similar to {$and: []}

            Assignee:
            kateryna.kamenieva@mongodb.com Katya Kamenieva
            Reporter:
            ben.shteinfeld@mongodb.com Ben Shteinfeld
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated: