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

Investigate and document BSON::Regexp::Raw as a valid field type

    • Type: Icon: Task Task
    • Resolution: Unresolved
    • Priority: Icon: Unknown Unknown
    • None
    • Affects Version/s: None
    • Component/s: None
    • Labels:

      After some discussion, it seems there are many differences between a BSON::Regexp::Raw type, and a user might want to work explicitly with those types.

      class User
        include Mongoid::Document
      
        field :reg, type: BSON::Regexp::Raw
      end
      
      u = User.create!(reg: BSON::Regexp::Raw.new("hello"))
      p u.reg
      # => #<BSON::Regexp::Raw:0x00007fcfa8317b10 @pattern="hello", @options="", @compiled=/hello/>
      u = User.find(u.id)
      p u.reg
      # => #<BSON::Regexp::Raw:0x00007fcfad2825d8 @pattern="hello", @options="">
      

      This already works. However this ticket could also be used to create a mongoize and demongoize method so that a string/regex assigned to this field can be coerced to a BSON::Regexp::Raw type.

            Assignee:
            Unassigned Unassigned
            Reporter:
            neil.shweky@mongodb.com Neil Shweky (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated: