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

Index creation on nested field broken due to key validation

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 12_01_17
    • Affects Version/s: 5.1.4
    • Component/s: None
    • Labels:
      None
    • Environment:
      Using mongo ruby driver in v2.3.0

      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!

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

              Created:
              Updated:
              Resolved: