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

Unable to create indexes on embedded document fields

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 12_01_17
    • Affects Version/s: None
    • Component/s: None
    • Labels:
      None

      Prior to recent changes (I think I was on something in between 0.7 and 0.8 I was able to create an index using:

      coll.create_index([['users.email', XGen::Mongo::ASCENDING]])

      On mongo-ruby-driver HEAD (71d7ff726b38f440d7df47b6d39cda3636370bfc) I get the following error:
      /var/lib/gems/1.8/gems/mongo-0.8/lib/mongo/util/bson.rb:108:in `serialize_key_value': key users.email must not contain '.' (RuntimeError)
      from /var/lib/gems/1.8/gems/mongo-0.8/lib/mongo/util/bson.rb:94:in `serialize'
      from /var/lib/gems/1.8/gems/mongo-0.8/lib/mongo/util/ordered_hash.rb:50:in `each'
      from /var/lib/gems/1.8/gems/mongo-0.8/lib/mongo/util/ordered_hash.rb:50:in `each'
      from /var/lib/gems/1.8/gems/mongo-0.8/lib/mongo/util/bson.rb:94:in `serialize'
      from /var/lib/gems/1.8/gems/mongo-0.8/lib/mongo/util/bson.rb:410:in `serialize_object_element'
      from /var/lib/gems/1.8/gems/mongo-0.8/lib/mongo/util/bson.rb:117:in `serialize_key_value'
      from /var/lib/gems/1.8/gems/mongo-0.8/lib/mongo/util/bson.rb:94:in `serialize'
      from /var/lib/gems/1.8/gems/mongo-0.8/lib/mongo/util/bson.rb:94:in `each'
      from /var/lib/gems/1.8/gems/mongo-0.8/lib/mongo/util/bson.rb:94:in `serialize'
      from /var/lib/gems/1.8/gems/mongo-0.8/lib/mongo/message/message.rb:62:in `write_doc'
      from /var/lib/gems/1.8/gems/mongo-0.8/lib/mongo/message/insert_message.rb:30:in `initialize'
      from /var/lib/gems/1.8/gems/mongo-0.8/lib/mongo/message/insert_message.rb:30:in `each'
      from /var/lib/gems/1.8/gems/mongo-0.8/lib/mongo/message/insert_message.rb:30:in `initialize'
      from /var/lib/gems/1.8/gems/mongo-0.8/lib/mongo/db.rb:476:in `new'
      from /var/lib/gems/1.8/gems/mongo-0.8/lib/mongo/db.rb:476:in `create_index'
      from /usr/lib/ruby/1.8/mutex_m.rb:67:in `synchronize'
      from /var/lib/gems/1.8/gems/mongo-0.8/lib/mongo/db.rb:475:in `create_index'
      from /var/lib/gems/1.8/gems/mongo-0.8/lib/mongo/collection.rb:132:in `create_index'

      Is there an alternate syntax for creating indexes on embedded document fields or is this a bug..?

            Assignee:
            mike Michael Dirolf
            Reporter:
            goosmurf Yun Huang Yong
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: