Uploaded image for project: 'MongoDB Shell'
  1. MongoDB Shell
  2. MONGOSH-623

Retrieving stored PCRE-style regex causes the shell to throw

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 0.15.6
    • Affects Version/s: None
    • Component/s: Bson
    • None
    • 1
    • Needed
    • Hide

      The shell cannot retrieve documents containing some types of regular expressions by default, namely, those which are not representable as JavaScript regular expressions.

      In order to retrieve them, the bsonRegExp: true option needs to be passed to the method in question. For example:

      db.coll.insertOne({ re: BSONRegExp('(?-i)AA_', 'im') })
      
      db.coll.find(); // fails
      db.coll.find({}, {}, { bsonRegExp: true }); // works
      
      Show
      The shell cannot retrieve documents containing some types of regular expressions by default, namely, those which are not representable as JavaScript regular expressions. In order to retrieve them, the bsonRegExp: true option needs to be passed to the method in question. For example: db.coll.insertOne({ re: BSONRegExp( '(?-i)AA_' , 'im' ) }) db.coll.find(); // fails db.coll.find({}, {}, { bsonRegExp: true }); // works
    • Iteration Firenze

      Problem Description

      If the shell retrieves a document from the server containing a BSONRegex field with an embedded PCRE expression, it will attempt to interpret the regex pattern under Javascript regex rules, and will fail.

      Steps to Reproduce

      See SERVER-54588.

      Expected Results

      The shell is capable of ingesting and displaying the document, including any non-Javascript-compatible regex fields.

      Actual Results

      The shell throws an exception when it attempts to interpret the PCRE regex.

      Additional Notes

      Drivers have already encountered this issue in the past and resolved it: DRIVERS-82.

            Assignee:
            Unassigned Unassigned
            Reporter:
            bernard.gorman@mongodb.com Bernard Gorman
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved: