Skip to content

Commit 0ce86be

Browse files
committed
Merge pull request #475 from estolfo/RUBY-799-drop-dups
RUBY-799 Mark drop_dups as deprecated in ensure_index and create_index
2 parents 31c7c87 + 2a0b156 commit 0ce86be

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

lib/mongo/collection.rb

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -518,8 +518,9 @@ def update(selector, document, opts={})
518518
# @option opts [Boolean] :unique (false) if true, this index will enforce a uniqueness constraint.
519519
# @option opts [Boolean] :background (false) indicate that the index should be built in the background. This
520520
# feature is only available in MongoDB >= 1.3.2.
521-
# @option opts [Boolean] :drop_dups (nil) If creating a unique index on a collection with pre-existing records,
522-
# this option will keep the first document the database indexes and drop all subsequent with duplicate values.
521+
# @option opts [Boolean] :drop_dups (nil) (DEPRECATED) If creating a unique index on a collection with
522+
# pre-existing records, this option will keep the first document the database indexes and drop all subsequent
523+
# with duplicate values.
523524
# @option opts [Integer] :bucket_size (nil) For use with geoHaystack indexes. Number of documents to group
524525
# together within a certain proximity to a given longitude and latitude.
525526
# @option opts [Integer] :min (nil) specify the minimum longitude and latitude for a geo index.
@@ -545,6 +546,10 @@ def update(selector, document, opts={})
545546
# @example A geospatial index with alternate longitude and latitude:
546547
# @restaurants.create_index([['location', Mongo::GEO2D]], :min => 500, :max => 500)
547548
#
549+
# @note The :drop_dups option is no longer supported by MongoDB starting with server version 2.7.5.
550+
# The option is silently ignored by the server and unique index builds using the option will
551+
# fail if a duplicate value is detected.
552+
#
548553
# @return [String] the name of the index created.
549554
def create_index(spec, opts={})
550555
options = opts.dup
@@ -572,6 +577,10 @@ def create_index(spec, opts={})
572577
# Time t+10min : @posts.ensure_index(:subject => Mongo::ASCENDING) -- calls create_index and
573578
# resets the 5 minute counter
574579
#
580+
# @note The :drop_dups option is no longer supported by MongoDB starting with server version 2.7.5.
581+
# The option is silently ignored by the server and unique index builds using the option will
582+
# fail if a duplicate value is detected.
583+
#
575584
# @return [String] the name of the index.
576585
def ensure_index(spec, opts={})
577586
now = Time.now.utc.to_i

0 commit comments

Comments
 (0)