$elemMatch of trivially true predicate misinterpreted after serialisation/deserialisation

XMLWordPrintableJSON

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

      9.0 and 8.0 disagree on the result set without the inhibit.

      db.local.drop();
      db.foreign.drop();
      db.local.insertOne({_id: 1, array: [0], a: 0});
      db.foreign.insertOne({a: 0});
      
      const norMatch = {
          $nor: [
              {m: {$elemMatch: {a: {$ne: 1}}}, array: {$not: {$elemMatch: {$nin: []}}}},
              {m: {$not: {$not: {$nin: []}}}, a: 1},
          ],
      };
      
      const lookupStage = {
          $lookup: {from: db.foreign.getName(), localField: "a", foreignField: "a", as: "m"},
      };
      
      db.local.aggregate([
          lookupStage,
          {$match: norMatch},
      ]);
      
      db.local.aggregate([
          lookupStage,
          {$_internalInhibitOptimization: {}},
          {$match: norMatch},
      ]);
       

            Assignee:
            James Harrison
            Reporter:
            Evan Bergeron
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved: