-
Type: Bug
-
Resolution: Unresolved
-
Priority: Major - P3
-
None
-
Affects Version/s: None
-
Component/s: Persistence
-
None
-
Ruby Drivers
When creating indexes that conflict (same keys different options) they are ignored. I would expect it to not be ignored if they have different names and raise an error if they have the same name but different options/keys.
require 'mongoid' Mongoid.configure do |config| config.clients.default = { hosts: ['localhost:27017'], database: 'bugs' } end class Foo include Mongoid::Document field :bar, type: String field :baz, type: String index({ bar: 1 }, { partial_filter_expression: { baz: '1' } }) index({ bar: 1 }, { name: 'partial_bar_2', partial_filter_expression: { baz: '2' } }) end Foo.create_indexes # I expect 3, 1 for _id and 2 i just created raise 'index didnt get created!' if Foo.collection.indexes.count != 3 class Foo2 include Mongoid::Document field :bar, type: String field :baz, type: String index({ bar: 1 }, { partial_filter_expression: { baz: '1' } }) index({ bar: 1 }, { partial_filter_expression: { baz: '2' } }) end Foo2.create_indexes # I expiect it to raise an error