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

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

    • Type: Icon: Bug Bug
    • Resolution: Works as Designed
    • Priority: Icon: Major - P3 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

      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@mongodb.com Jacob Evans
            Reporter:
            alien Boris Petrov
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: