remove drop_dups index option, deprecated with MongoDB3
This commit is contained in:
		| @@ -10,8 +10,10 @@ Development | |||||||
| - Fixed a bug causing inaccurate query results, while combining ``__raw__`` and regular filters for the same field #2264 | - Fixed a bug causing inaccurate query results, while combining ``__raw__`` and regular filters for the same field #2264 | ||||||
| - Add support for the `elemMatch` projection operator in .fields() (e.g BlogPost.objects.fields(elemMatch__comments="test")) #2267 | - Add support for the `elemMatch` projection operator in .fields() (e.g BlogPost.objects.fields(elemMatch__comments="test")) #2267 | ||||||
| - DictField validate failed without default connection (bug introduced in 0.19.0) #2239 | - DictField validate failed without default connection (bug introduced in 0.19.0) #2239 | ||||||
| - Remove name parameter in Field constructor e.g `StringField(name="...")`, it was deprecated a while ago in favor of db_field | - Remove methods deprecated years ago: | ||||||
| - Remove method queryset.slave_okay() that was deprecated a while ago and disappeared since pymongo3 |     - name parameter in Field constructor e.g `StringField(name="...")`, was replaced by db_field | ||||||
|  |     - Queryset.slave_okay() was deprecated since pymongo3 | ||||||
|  |     - dropDups was dropped with MongoDB3 | ||||||
|  |  | ||||||
| Changes in 0.19.1 | Changes in 0.19.1 | ||||||
| ================= | ================= | ||||||
|   | |||||||
| @@ -555,7 +555,6 @@ There are a few top level defaults for all indexes that can be set:: | |||||||
|             'index_background': True, |             'index_background': True, | ||||||
|             'index_cls': False, |             'index_cls': False, | ||||||
|             'auto_create_index': True, |             'auto_create_index': True, | ||||||
|             'index_drop_dups': True, |  | ||||||
|         } |         } | ||||||
|  |  | ||||||
|  |  | ||||||
| @@ -574,11 +573,6 @@ There are a few top level defaults for all indexes that can be set:: | |||||||
|     in systems where indexes are managed separately. Disabling this will improve |     in systems where indexes are managed separately. Disabling this will improve | ||||||
|     performance. |     performance. | ||||||
|  |  | ||||||
| :attr:`index_drop_dups` (Optional) |  | ||||||
|     Set the default value for if an index should drop duplicates |  | ||||||
|     Since MongoDB 3.0 drop_dups is not supported anymore. Raises a Warning |  | ||||||
|     and has no effect |  | ||||||
|  |  | ||||||
|  |  | ||||||
| Compound Indexes and Indexing sub documents | Compound Indexes and Indexing sub documents | ||||||
| ------------------------------------------- | ------------------------------------------- | ||||||
|   | |||||||
| @@ -284,7 +284,6 @@ class TopLevelDocumentMetaclass(DocumentMetaclass): | |||||||
|                 "indexes": [],  # indexes to be ensured at runtime |                 "indexes": [],  # indexes to be ensured at runtime | ||||||
|                 "id_field": None, |                 "id_field": None, | ||||||
|                 "index_background": False, |                 "index_background": False, | ||||||
|                 "index_drop_dups": False, |  | ||||||
|                 "index_opts": None, |                 "index_opts": None, | ||||||
|                 "delete_rules": None, |                 "delete_rules": None, | ||||||
|                 # allow_inheritance can be True, False, and None. True means |                 # allow_inheritance can be True, False, and None. True means | ||||||
|   | |||||||
| @@ -851,17 +851,13 @@ class Document(six.with_metaclass(TopLevelDocumentMetaclass, BaseDocument)): | |||||||
|         index_spec = cls._build_index_spec(keys) |         index_spec = cls._build_index_spec(keys) | ||||||
|         index_spec = index_spec.copy() |         index_spec = index_spec.copy() | ||||||
|         fields = index_spec.pop("fields") |         fields = index_spec.pop("fields") | ||||||
|         drop_dups = kwargs.get("drop_dups", False) |  | ||||||
|         if drop_dups: |  | ||||||
|             msg = "drop_dups is deprecated and is removed when using PyMongo 3+." |  | ||||||
|             warnings.warn(msg, DeprecationWarning) |  | ||||||
|         index_spec["background"] = background |         index_spec["background"] = background | ||||||
|         index_spec.update(kwargs) |         index_spec.update(kwargs) | ||||||
|  |  | ||||||
|         return cls._get_collection().create_index(fields, **index_spec) |         return cls._get_collection().create_index(fields, **index_spec) | ||||||
|  |  | ||||||
|     @classmethod |     @classmethod | ||||||
|     def ensure_index(cls, key_or_list, drop_dups=False, background=False, **kwargs): |     def ensure_index(cls, key_or_list, background=False, **kwargs): | ||||||
|         """Ensure that the given indexes are in place. Deprecated in favour |         """Ensure that the given indexes are in place. Deprecated in favour | ||||||
|         of create_index. |         of create_index. | ||||||
|  |  | ||||||
| @@ -869,12 +865,7 @@ class Document(six.with_metaclass(TopLevelDocumentMetaclass, BaseDocument)): | |||||||
|             construct a multi-field index); keys may be prefixed with a **+** |             construct a multi-field index); keys may be prefixed with a **+** | ||||||
|             or a **-** to determine the index ordering |             or a **-** to determine the index ordering | ||||||
|         :param background: Allows index creation in the background |         :param background: Allows index creation in the background | ||||||
|         :param drop_dups: Was removed/ignored with MongoDB >2.7.5. The value |  | ||||||
|             will be removed if PyMongo3+ is used |  | ||||||
|         """ |         """ | ||||||
|         if drop_dups: |  | ||||||
|             msg = "drop_dups is deprecated and is removed when using PyMongo 3+." |  | ||||||
|             warnings.warn(msg, DeprecationWarning) |  | ||||||
|         return cls.create_index(key_or_list, background=background, **kwargs) |         return cls.create_index(key_or_list, background=background, **kwargs) | ||||||
|  |  | ||||||
|     @classmethod |     @classmethod | ||||||
| @@ -887,12 +878,8 @@ class Document(six.with_metaclass(TopLevelDocumentMetaclass, BaseDocument)): | |||||||
|                   `auto_create_index` to False in the documents meta data |                   `auto_create_index` to False in the documents meta data | ||||||
|         """ |         """ | ||||||
|         background = cls._meta.get("index_background", False) |         background = cls._meta.get("index_background", False) | ||||||
|         drop_dups = cls._meta.get("index_drop_dups", False) |  | ||||||
|         index_opts = cls._meta.get("index_opts") or {} |         index_opts = cls._meta.get("index_opts") or {} | ||||||
|         index_cls = cls._meta.get("index_cls", True) |         index_cls = cls._meta.get("index_cls", True) | ||||||
|         if drop_dups: |  | ||||||
|             msg = "drop_dups is deprecated and is removed when using PyMongo 3+." |  | ||||||
|             warnings.warn(msg, DeprecationWarning) |  | ||||||
|  |  | ||||||
|         collection = cls._get_collection() |         collection = cls._get_collection() | ||||||
|         # 746: when connection is via mongos, the read preference is not necessarily an indication that |         # 746: when connection is via mongos, the read preference is not necessarily an indication that | ||||||
|   | |||||||
| @@ -806,18 +806,6 @@ class TestIndexes(unittest.TestCase): | |||||||
|         info = Log.objects._collection.index_information() |         info = Log.objects._collection.index_information() | ||||||
|         assert 3600 == info["created_1"]["expireAfterSeconds"] |         assert 3600 == info["created_1"]["expireAfterSeconds"] | ||||||
|  |  | ||||||
|     def test_index_drop_dups_silently_ignored(self): |  | ||||||
|         class Customer(Document): |  | ||||||
|             cust_id = IntField(unique=True, required=True) |  | ||||||
|             meta = { |  | ||||||
|                 "indexes": ["cust_id"], |  | ||||||
|                 "index_drop_dups": True, |  | ||||||
|                 "allow_inheritance": False, |  | ||||||
|             } |  | ||||||
|  |  | ||||||
|         Customer.drop_collection() |  | ||||||
|         Customer.objects.first() |  | ||||||
|  |  | ||||||
|     def test_unique_and_indexes(self): |     def test_unique_and_indexes(self): | ||||||
|         """Ensure that 'unique' constraints aren't overridden by |         """Ensure that 'unique' constraints aren't overridden by | ||||||
|         meta.indexes. |         meta.indexes. | ||||||
| @@ -1058,10 +1046,6 @@ class TestIndexes(unittest.TestCase): | |||||||
|                 del index_info[key][ |                 del index_info[key][ | ||||||
|                     "ns" |                     "ns" | ||||||
|                 ]  # drop the index namespace - we don't care about that here, MongoDB 3+ |                 ]  # drop the index namespace - we don't care about that here, MongoDB 3+ | ||||||
|             if "dropDups" in index_info[key]: |  | ||||||
|                 del index_info[key][ |  | ||||||
|                     "dropDups" |  | ||||||
|                 ]  # drop the index dropDups - it is deprecated in MongoDB 3+ |  | ||||||
|  |  | ||||||
|         assert index_info == { |         assert index_info == { | ||||||
|             "txt_1": {"key": [("txt", 1)], "background": False}, |             "txt_1": {"key": [("txt", 1)], "background": False}, | ||||||
|   | |||||||
| @@ -523,7 +523,6 @@ class TestInheritance(MongoDBTestCase): | |||||||
|  |  | ||||||
|         defaults = { |         defaults = { | ||||||
|             "index_background": True, |             "index_background": True, | ||||||
|             "index_drop_dups": True, |  | ||||||
|             "index_opts": {"hello": "world"}, |             "index_opts": {"hello": "world"}, | ||||||
|             "allow_inheritance": True, |             "allow_inheritance": True, | ||||||
|             "queryset_class": "QuerySet", |             "queryset_class": "QuerySet", | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user