Queries should not fail with type error when $type provides the correct filter

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Works as Designed
    • Priority: Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • ALL
    • Hide
      db.objects.insert({ x: 3 })
      
      db.objects.find(
          { $and: [
              { x: { $type: 4 } },
              { $or: [
                  { $expr: { $in: ['$y', '$x'] } },
                  { $expr: { $in: ['$y', '$x'] } }
              ] }
          ] },
      )
      
      Show
      db.objects.insert({ x: 3 }) db.objects.find( { $and: [ { x: { $type: 4 } }, { $or: [ { $expr: { $in: ['$y', '$x'] } }, { $expr: { $in: ['$y', '$x'] } } ] } ] }, )
    • Query 2019-12-30
    • None
    • 3
    • None
    • None
    • None
    • None
    • None
    • None

      Original Summary

      $and does not short-circuit

      Original Description

      I think this is a bug. Check the "Steps To Reproduce". The interesting thing is that if one of the two expressions in the `$or` part is removed, then the query executes fine. Otherwise it leads to `$in requires an array as a second argument, found: objectId`.

            Assignee:
            Jacob Evans (Inactive)
            Reporter:
            Boris Petrov
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: