Uploaded image for project: 'Ruby Driver'
  1. Ruby Driver
  2. RUBY-1167

BSON::String::IllegalKey when defining indexes on embedded document fields

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 2.4.0
    • Affects Version/s: 2.3.0
    • Component/s: None
    • Labels:
      None
    • Environment:
      mongo-2.3.0

      The issue is known to happen with 5.1.4 and 5.1.5, but the most important factor is using mongo ruby driver 2.3.0.

      As seen in the documentation :

      "You can define indexes on embedded document fields as well."

      https://docs.mongodb.com/ruby-driver/master/tutorials/5.1.0/mongoid-indexes/

      This does not work anymore.

      You can easily break the RSpec suite by adding the following line to spec/app/models/person.rb :

      index "addresses.street" => 1

      The RSpec suite will then fail at multiple places, throwing BSON::String::IllegalKey exceptions :

      Failure/Error: collection.indexes.create_one(key, options)

      BSON::String::IllegalKey:
      'addresses.street' is an illegal key in MongoDB. Keys may not start with '$' or contain a '.'

      You can also trigger the bug by executing the create_indexes rake task.

      The only workaround is to use mongo driver < 2.3.0.

            Assignee:
            emily.stolfo Emily Stolfo
            Reporter:
            sylvain-8422 Sylvain Bernier
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: