Skip to content

Commit c0e78e6

Browse files
Remove drop_dup options from index macro (#5266)
Co-authored-by: shields <[email protected]>
1 parent 64b94c6 commit c0e78e6

File tree

7 files changed

+29
-53
lines changed

7 files changed

+29
-53
lines changed

docs/reference/indexes.txt

Lines changed: 19 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -61,39 +61,6 @@ Indexes can be sparse:
6161
index({ ssn: -1 }, { sparse: true })
6262
end
6363

64-
*Deprecated:* In MongoDB 4.0 and earlier, users could control whether to build indexes
65-
in the foreground (blocking) or background (non-blocking, but less efficient) using the
66-
``background`` option.
67-
68-
.. code-block:: ruby
69-
70-
class Person
71-
include Mongoid::Document
72-
field :ssn
73-
index({ ssn: 1 }, { unique: true, background: true })
74-
end
75-
76-
The default value of ``background`` is controlled by Mongoid's
77-
``background_indexing`` :ref:`configuration option <configuration-options>`.
78-
79-
The ``background`` option has `no effect as of MongoDB 4.2
80-
<https://www.mongodb.com/docs/manual/core/index-creation/#comparison-to-foreground-and-background-builds>`_.
81-
82-
*Deprecated:* When using MongoDB 2.6, you can drop the duplicate entries
83-
for unique indexes that are defined for a column that might
84-
already have duplicate values by specifying the ``drop_dups`` option:
85-
86-
.. code-block:: ruby
87-
88-
class Person
89-
include Mongoid::Document
90-
field :ssn
91-
index({ ssn: 1 }, { unique: true, drop_dups: true })
92-
end
93-
94-
The ``drop_dups`` option has been `removed as of MongoDB 3.0
95-
<https://mongodb.com/docs/manual/release-notes/3.0-compatibility/#remove-dropdups-option>`_.
96-
9764
For geospatial indexes, make sure the field being indexed is of type Array:
9865

9966
.. code-block:: ruby
@@ -126,6 +93,25 @@ This only works on the association macro that the foreign key is stored on:
12693
has_and_belongs_to_many :preferences, index: true
12794
end
12895

96+
*Deprecated:* In MongoDB 4.0 and earlier, users could control whether to build indexes
97+
in the foreground (blocking) or background (non-blocking, but less efficient) using the
98+
``background`` option.
99+
100+
.. code-block:: ruby
101+
102+
class Person
103+
include Mongoid::Document
104+
field :ssn
105+
index({ ssn: 1 }, { unique: true, background: true })
106+
end
107+
108+
The default value of ``background`` is controlled by Mongoid's
109+
``background_indexing`` :ref:`configuration option <configuration-options>`.
110+
111+
The ``background`` option has `no effect as of MongoDB 4.2
112+
<https://www.mongodb.com/docs/manual/core/index-creation/#comparison-to-foreground-and-background-builds>`_.
113+
114+
129115
Index Management Rake Tasks
130116
===========================
131117

docs/release-notes/mongoid-8.0.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,13 @@ Mongoid 7 behavior:
303303
end
304304

305305

306+
Removed ``:drop_dups`` Option from Indexes
307+
------------------------------------------
308+
309+
The ``:drop_dups`` option has been removed from the ``index`` macro. This option
310+
was specific to MongoDB server 2.6 and earlier, which Mongoid no longer supports.
311+
312+
306313
Removed ``Document#to_a`` Method
307314
--------------------------------
308315

lib/config/locales/en.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,6 @@ en:
195195
Valid options are:\n
196196
\_\_background: true|false\n
197197
\_\_database: 'database_name'\n
198-
\_\_drop_dups: true|false\n
199198
\_\_name: 'index_name'\n
200199
\_\_sparse: true|false\n
201200
\_\_unique: true|false\n

lib/mongoid/indexable/specification.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ def normalize_key(key)
8686
# @api private
8787
#
8888
# @example Normalize the index options.
89-
# specification.normalize_options(drop_dups: true)
89+
# specification.normalize_options(unique: true)
9090
#
9191
# @param [ Hash ] opts The index options.
9292
#

lib/mongoid/indexable/validators/options.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ module Options
1313
:database,
1414
:default_language,
1515
:language_override,
16-
:drop_dups,
1716
:name,
1817
:sparse,
1918
:unique,

spec/mongoid/indexable/specification_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@
8585
Band,
8686
{ name: 1, title: 1, years: -1 },
8787
background: true,
88-
drop_dups: true
88+
unique: true
8989
)
9090
end
9191

@@ -98,7 +98,7 @@
9898
end
9999

100100
it "normalizes the options" do
101-
expect(spec.options).to eq(background: true, drop_dups: true)
101+
expect(spec.options).to eq(background: true, unique: true)
102102
end
103103
end
104104

spec/mongoid/indexable_spec.rb

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -262,21 +262,6 @@ def self.hereditary?
262262
end
263263
end
264264

265-
context "when providing a drop_dups option" do
266-
267-
before do
268-
klass.index({ name: 1 }, drop_dups: true)
269-
end
270-
271-
let(:options) do
272-
klass.index_specification(name: 1).options
273-
end
274-
275-
it "sets the index with drop_dups option" do
276-
expect(options).to eq(drop_dups: true)
277-
end
278-
end
279-
280265
context "when providing a sparse option" do
281266

282267
before do

0 commit comments

Comments
 (0)