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

Regexp::Raw usage breaks when Mongoid is loaded

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 7.1.4
    • Affects Version/s: None
    • Component/s: Query
    • Fully Compatible

      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
      

            Assignee:
            oleg.pudeyev@mongodb.com Oleg Pudeyev (Inactive)
            Reporter:
            oleg.pudeyev@mongodb.com Oleg Pudeyev (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: