Skip to content

Commit f49baf5

Browse files
authored
Merge pull request #2285 from bagerard/remove_drop_dups
Remove drop_dups that was deprecated with Mongo3
2 parents 6cc6229 + 476b07a commit f49baf5

File tree

6 files changed

+6
-42
lines changed

6 files changed

+6
-42
lines changed

docs/changelog.rst

+5-4
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,14 @@ Development
77
===========
88
- (Fill this out as you fix issues and develop your features).
99
- Add Mongo 4.0 to Travis
10-
- BREAKING CHANGE: Removed ``Queryset._ensure_indexes`` and ``Queryset.ensure_indexes`` that were deprecated in 2013.
11-
``Document.ensure_indexes`` still exists and is the right method to use
1210
- Fixed a bug causing inaccurate query results, while combining ``__raw__`` and regular filters for the same field #2264
1311
- Add support for the `elemMatch` projection operator in .fields() (e.g BlogPost.objects.fields(elemMatch__comments="test")) #2267
1412
- DictField validate failed without default connection (bug introduced in 0.19.0) #2239
15-
- Remove name parameter in Field constructor e.g `StringField(name="...")`, it was deprecated a while ago in favor of db_field
16-
- Remove method queryset.slave_okay() that was deprecated a while ago and disappeared since pymongo3
13+
- Remove methods deprecated years ago:
14+
- name parameter in Field constructor e.g `StringField(name="...")`, was replaced by db_field
15+
- Queryset.slave_okay() was deprecated since pymongo3
16+
- dropDups was dropped with MongoDB3
17+
- ``Queryset._ensure_indexes`` and ``Queryset.ensure_indexes``, the right method to use is ``Document.ensure_indexes``
1718

1819
Changes in 0.19.1
1920
=================

docs/guide/defining-documents.rst

-6
Original file line numberDiff line numberDiff line change
@@ -555,7 +555,6 @@ There are a few top level defaults for all indexes that can be set::
555555
'index_background': True,
556556
'index_cls': False,
557557
'auto_create_index': True,
558-
'index_drop_dups': True,
559558
}
560559

561560

@@ -574,11 +573,6 @@ There are a few top level defaults for all indexes that can be set::
574573
in systems where indexes are managed separately. Disabling this will improve
575574
performance.
576575

577-
:attr:`index_drop_dups` (Optional)
578-
Set the default value for if an index should drop duplicates
579-
Since MongoDB 3.0 drop_dups is not supported anymore. Raises a Warning
580-
and has no effect
581-
582576

583577
Compound Indexes and Indexing sub documents
584578
-------------------------------------------

mongoengine/base/metaclasses.py

-1
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,6 @@ def __new__(mcs, name, bases, attrs):
284284
"indexes": [], # indexes to be ensured at runtime
285285
"id_field": None,
286286
"index_background": False,
287-
"index_drop_dups": False,
288287
"index_opts": None,
289288
"delete_rules": None,
290289
# allow_inheritance can be True, False, and None. True means

mongoengine/document.py

+1-14
Original file line numberDiff line numberDiff line change
@@ -851,30 +851,21 @@ def create_index(cls, keys, background=False, **kwargs):
851851
index_spec = cls._build_index_spec(keys)
852852
index_spec = index_spec.copy()
853853
fields = index_spec.pop("fields")
854-
drop_dups = kwargs.get("drop_dups", False)
855-
if drop_dups:
856-
msg = "drop_dups is deprecated and is removed when using PyMongo 3+."
857-
warnings.warn(msg, DeprecationWarning)
858854
index_spec["background"] = background
859855
index_spec.update(kwargs)
860856

861857
return cls._get_collection().create_index(fields, **index_spec)
862858

863859
@classmethod
864-
def ensure_index(cls, key_or_list, drop_dups=False, background=False, **kwargs):
860+
def ensure_index(cls, key_or_list, background=False, **kwargs):
865861
"""Ensure that the given indexes are in place. Deprecated in favour
866862
of create_index.
867863
868864
:param key_or_list: a single index key or a list of index keys (to
869865
construct a multi-field index); keys may be prefixed with a **+**
870866
or a **-** to determine the index ordering
871867
:param background: Allows index creation in the background
872-
:param drop_dups: Was removed/ignored with MongoDB >2.7.5. The value
873-
will be removed if PyMongo3+ is used
874868
"""
875-
if drop_dups:
876-
msg = "drop_dups is deprecated and is removed when using PyMongo 3+."
877-
warnings.warn(msg, DeprecationWarning)
878869
return cls.create_index(key_or_list, background=background, **kwargs)
879870

880871
@classmethod
@@ -887,12 +878,8 @@ def ensure_indexes(cls):
887878
`auto_create_index` to False in the documents meta data
888879
"""
889880
background = cls._meta.get("index_background", False)
890-
drop_dups = cls._meta.get("index_drop_dups", False)
891881
index_opts = cls._meta.get("index_opts") or {}
892882
index_cls = cls._meta.get("index_cls", True)
893-
if drop_dups:
894-
msg = "drop_dups is deprecated and is removed when using PyMongo 3+."
895-
warnings.warn(msg, DeprecationWarning)
896883

897884
collection = cls._get_collection()
898885
# 746: when connection is via mongos, the read preference is not necessarily an indication that

tests/document/test_indexes.py

-16
Original file line numberDiff line numberDiff line change
@@ -806,18 +806,6 @@ class Log(Document):
806806
info = Log.objects._collection.index_information()
807807
assert 3600 == info["created_1"]["expireAfterSeconds"]
808808

809-
def test_index_drop_dups_silently_ignored(self):
810-
class Customer(Document):
811-
cust_id = IntField(unique=True, required=True)
812-
meta = {
813-
"indexes": ["cust_id"],
814-
"index_drop_dups": True,
815-
"allow_inheritance": False,
816-
}
817-
818-
Customer.drop_collection()
819-
Customer.objects.first()
820-
821809
def test_unique_and_indexes(self):
822810
"""Ensure that 'unique' constraints aren't overridden by
823811
meta.indexes.
@@ -1058,10 +1046,6 @@ class TestChildDoc(TestDoc):
10581046
del index_info[key][
10591047
"ns"
10601048
] # drop the index namespace - we don't care about that here, MongoDB 3+
1061-
if "dropDups" in index_info[key]:
1062-
del index_info[key][
1063-
"dropDups"
1064-
] # drop the index dropDups - it is deprecated in MongoDB 3+
10651049

10661050
assert index_info == {
10671051
"txt_1": {"key": [("txt", 1)], "background": False},

tests/document/test_inheritance.py

-1
Original file line numberDiff line numberDiff line change
@@ -523,7 +523,6 @@ def test_abstract_documents(self):
523523

524524
defaults = {
525525
"index_background": True,
526-
"index_drop_dups": True,
527526
"index_opts": {"hello": "world"},
528527
"allow_inheritance": True,
529528
"queryset_class": "QuerySet",

0 commit comments

Comments
 (0)