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

Index creation on nested field broken due to key validation

    XMLWordPrintableJSON

Details

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Major - P3 Major - P3
    • 12_01_17
    • 5.1.4
    • None
    • None
    • Using mongo ruby driver in v2.3.0

    Description

      Using the following code I get an error regarding an invalid key, because it contains a dot, on Mongoid v5.1.4 + mongo-ruby-driver v2.3.0 when running `rake db:mongoid:create_indexes`.
      Downgrading to mongo-ruby-driver v.2.2.x resolved the issue.
      Also works in mongoid 4.x.

      post.rb

      class Post
        include Mongoid::Document
       
        embeds_many :comments
        index({ 'comment.ref' => 1 })
      end
      

      comment.rb

      class Comment
        include Mongoid::Document
       
        field :ref, type: String
        embedded_in :post
      end
      

      I can provide you with the full stacktrace later if required.

      Cheers!

      Attachments

        Activity

          People

            Unassigned Unassigned
            christophgeschwind Christoph Geschwind
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: