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

[CQF] reverseComparisonOp negates when it should flip

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 6.3.0-rc0
    • Affects Version/s: None
    • Component/s: None
    • Query Optimization
    • Fully Compatible
    • QO 2022-12-26

      With forceBonsai enabled:

      > db.c.find()
      { "_id" : ObjectId("6377f2f520fd1e38034e8012"), "a" : 1 }
      { "_id" : ObjectId("6377f2f720fd1e38034e8014"), "a" : 2 }
      { "_id" : ObjectId("6377f2f920fd1e38034e8016"), "a" : 3 }
      > db.c.find({$expr: {$lt: [2, "$a"]}})
      { "_id" : ObjectId("6377f2f720fd1e38034e8014"), "a" : 2 }
      { "_id" : ObjectId("6377f2f920fd1e38034e8016"), "a" : 3 }
      

      The problem is `reverseComparisonOp` is supposed to flip the argument order (Lt to Gt), but it converts Lt to Gte instead. Possibly we were confusing "flip argument order" with "negate boolean result".

            Assignee:
            will.buerger@mongodb.com Will Buerger
            Reporter:
            david.percy@mongodb.com David Percy
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: