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

$regex $options doesn't re-parse correctly

    • Query Integration
    • Fully Compatible
    • ALL
    • v7.3

      coll.find({x: {$regex: ".*", $options: "i"}}).toArray(); 

      and

      coll.find({x: {$regex: ".*"}}).toArray(); 

      (incorrectly) have the same query shape: 

      "queryShape" : {
          "cmdNs" : {
              "db" : "test",
              "coll" : "c"
           },
           "command" : "find",
           "filter" : {
               "x" : {
                   "$regex" : "?string"
               }
           }
      }

      This is likely because the representative value for $regex $options is "", which must get re-parsed as "we have no $options". The result is that we end up with duplicate shapes in the $queryStats output when two queries that are the same except for the existence of $options are run. 

            Assignee:
            mariano.shaar@mongodb.com Mariano Shaar
            Reporter:
            alyssa.clark@mongodb.com Alyssa Clark
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: