Uploaded image for project: 'Mongoid'
  1. Mongoid
  2. MONGOID-4873

Regexp::Raw usage breaks when Mongoid is loaded

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 7.1.4
    • Component/s: Query
    • Labels:
    • Backwards Compatibility:
      Fully Compatible

      Description

      https://docs.mongodb.com/ruby-driver/master/tutorials/bson-v4/#regular-expressions gives the following code as an example:

      Regexp::Raw.new("^b403158")
      

      This works when BSON is the only loaded library and when the driver is loaded, but breaks when Mongoid is also loaded:

      irb(main):001:0> Regexp::Raw.new("^b403158")
      Traceback (most recent call last):
              4: from /home/w/.rbenv/versions/2.7/bin/irb:23:in `<main>'
              3: from /home/w/.rbenv/versions/2.7/bin/irb:23:in `load'
              2: from /home/w/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/irb-1.2.1/exe/irb:11:in `<top (required)>'
              1: from (irb):1
      NoMethodError (undefined method `new' for Mongoid::Criteria::Queryable::Extensions::Regexp::Raw:Module)
      

      It looks like Mongoid has its own Raw module that interferes:

      carbon% irb -rmongoid
      irb(main):001:0> Regexp::Raw
      => Mongoid::Criteria::Queryable::Extensions::Regexp::Raw
      

        Attachments

          Activity

            People

            Assignee:
            oleg.pudeyev Oleg Pudeyev
            Reporter:
            oleg.pudeyev Oleg Pudeyev
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: