Drop the deprecated "format" param from BaseQuerySet.explain (#2113)

That option was pretty useless. You can very easily do:
```
import pprint
(...)

plan = SomeDoc.objects(...).explain()
pprint.pformat(plan)
```
This commit is contained in:
Stefan Wójcik 2019-07-01 10:18:47 +02:00 committed by GitHub
parent bc14f2cdaa
commit d0b87f7f82
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 17 deletions

View File

@ -6,6 +6,7 @@ Changelog
Development Development
=========== ===========
- (Fill this out as you fix issues and develop your features). - (Fill this out as you fix issues and develop your features).
- BREAKING CHANGE: Removed the deprecated `format` param from `QuerySet.explain` #2113
- BREAKING CHANGE: Renamed `MongoEngineConnectionError` to `ConnectionFailure` #2111 - BREAKING CHANGE: Renamed `MongoEngineConnectionError` to `ConnectionFailure` #2111
- If you catch/use `MongoEngineConnectionError` in your code, you'll have to rename it. - If you catch/use `MongoEngineConnectionError` in your code, you'll have to rename it.
- BREAKING CHANGE: Positional arguments when instantiating a document are no longer supported. #2103 - BREAKING CHANGE: Positional arguments when instantiating a document are no longer supported. #2103

View File

@ -2,7 +2,6 @@ from __future__ import absolute_import
import copy import copy
import itertools import itertools
import pprint
import re import re
import warnings import warnings
@ -1109,25 +1108,11 @@ class BaseQuerySet(object):
""" """
return self._chainable_method("comment", text) return self._chainable_method("comment", text)
def explain(self, format=False): def explain(self):
"""Return an explain plan record for the """Return an explain plan record for the
:class:`~mongoengine.queryset.QuerySet`\ 's cursor. :class:`~mongoengine.queryset.QuerySet`\ 's cursor.
:param format: format the plan before returning it
""" """
plan = self._cursor.explain() return self._cursor.explain()
# TODO remove this option completely - it's useless. If somebody
# wants to pretty-print the output, they easily can.
if format:
msg = (
'"format" param of BaseQuerySet.explain has been '
"deprecated and will be removed in future versions."
)
warnings.warn(msg, DeprecationWarning)
plan = pprint.pformat(plan)
return plan
# DEPRECATED. Has no more impact on PyMongo 3+ # DEPRECATED. Has no more impact on PyMongo 3+
def snapshot(self, enabled): def snapshot(self, enabled):