diff options
| author | Tim Graham <timograham@gmail.com> | 2015-01-30 11:23:20 -0500 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2015-01-30 12:51:12 -0500 |
| commit | 293fd5da5b8c7b79bd34ef793ab45c1bb8ac69ea (patch) | |
| tree | 06f8536d8304f98979851c8ad7597d79a6c43923 /django | |
| parent | 955f70904a3762894162b46c9bc97cc9abcee5dc (diff) | |
Reverted "Fixed #6785 -- Made QuerySet.get() fetch a limited number of rows."
This reverts commit da79ccca1d34f427952cce4555e598a700adb8de.
This optimized the unsuccessful case at the expense of the successful one.
Diffstat (limited to 'django')
| -rw-r--r-- | django/db/models/query.py | 16 |
1 files changed, 4 insertions, 12 deletions
diff --git a/django/db/models/query.py b/django/db/models/query.py index b2d210f2bc..016f89b198 100644 --- a/django/db/models/query.py +++ b/django/db/models/query.py @@ -23,10 +23,6 @@ from django.utils import six from django.utils import timezone from django.utils.version import get_version -# The maximum number (one less than the max to be precise) of results to fetch -# in a get() query -MAX_GET_RESULTS = 20 - # The maximum number of items to display in a QuerySet.__repr__ REPR_OUTPUT_SIZE = 20 @@ -379,21 +375,17 @@ class QuerySet(object): clone = self.filter(*args, **kwargs) if self.query.can_filter(): clone = clone.order_by() - if (not clone.query.select_for_update or - connections[self.db].features.supports_select_for_update_with_limit): - clone = clone[:MAX_GET_RESULTS + 1] num = len(clone) if num == 1: return clone._result_cache[0] if not num: raise self.model.DoesNotExist( "%s matching query does not exist." % - self.model._meta.object_name) - raise self.model.MultipleObjectsReturned( - "get() returned more than one %s -- it returned %s!" % ( - self.model._meta.object_name, - num if num <= MAX_GET_RESULTS else 'more than %s' % MAX_GET_RESULTS + self.model._meta.object_name ) + raise self.model.MultipleObjectsReturned( + "get() returned more than one %s -- it returned %s!" % + (self.model._meta.object_name, num) ) def create(self, **kwargs): |
