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

Regression on master with {$regex: /foo/i}

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Minor - P4 Minor - P4
    • 2.5.2
    • Affects Version/s: 2.5.1
    • Component/s: None
    • Labels:
      None
    • Environment:
      OSX, master built at revision 6e28cfc.
    • Fully Compatible
    • ALL

      On Mongo 2.4.4:

      > db.y.insert(

      {a:'foo'}

      )
      > db.y.findOne({a: {$regex: /O/i}})

      { "_id" : ObjectId("51f1ba8aa9b3808265d87c80"), "a" : "foo" }

      On master:

      > db.y.insert(

      {a: 'foo'}

      )
      > db.y.findOne({a: {$regex: /O/i}})
      null

      This only happens if you use `$regex` and you put the options directly on the BSON regex. `

      {a: /O/i}

      ` and `{$regex: 'O', $options: 'i'}` have the same behavior as in 2.4.

      This is presumably because in `expression_parser.cpp` in `MatchExpressionParser::_parseRegexDocument`, if `$regex` points to a `RegEx`, we only look at its `regex()` and not at its `regexFlags()` too.

            Assignee:
            andrew.aldridge@mongodb.com Andrew Aldridge
            Reporter:
            glasser David Glasser
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: