summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--django/db/models/sql/query.py5
-rw-r--r--tests/regressiontests/queries/models.py5
2 files changed, 8 insertions, 2 deletions
diff --git a/django/db/models/sql/query.py b/django/db/models/sql/query.py
index 9639ff4956..ce3b49cd42 100644
--- a/django/db/models/sql/query.py
+++ b/django/db/models/sql/query.py
@@ -1616,8 +1616,9 @@ class Query(object):
if self.ordering_aliases:
result = order_modified_iter(cursor, len(self.ordering_aliases),
self.connection.features.empty_fetchmany_value)
- result = iter((lambda: cursor.fetchmany(GET_ITERATOR_CHUNK_SIZE)),
- self.connection.features.empty_fetchmany_value)
+ else:
+ result = iter((lambda: cursor.fetchmany(GET_ITERATOR_CHUNK_SIZE)),
+ self.connection.features.empty_fetchmany_value)
if not self.connection.features.can_use_chunked_reads:
# If we are using non-chunked reads, we return the same data
# structure as normally, but ensure it is all read into memory
diff --git a/tests/regressiontests/queries/models.py b/tests/regressiontests/queries/models.py
index 847d515422..51cae7cde8 100644
--- a/tests/regressiontests/queries/models.py
+++ b/tests/regressiontests/queries/models.py
@@ -822,6 +822,11 @@ Bug #7759 -- count should work with a partially read result set.
... break
True
+Bug #7791 -- there were "issues" when ordering and distinct-ing on fields
+related via ForeignKeys.
+>>> Note.objects.order_by('extrainfo__info').distinct()
+[<Note: n3>, <Note: n1>, <Note: n2>]
+
"""}
# In Python 2.3, exceptions raised in __len__ are swallowed (Python issue