summaryrefslogtreecommitdiff
path: root/tests/queries/test_iterator.py
diff options
context:
space:
mode:
authorAndrew Brown <brownan@gmail.com>2018-07-20 14:54:14 -0400
committerTim Graham <timograham@gmail.com>2018-07-25 18:08:57 -0400
commit55810d94d03728dcad9f53d5b9e21565627aeade (patch)
tree4ed3a687b7f2d8d895bb86a75c18706d1c90f396 /tests/queries/test_iterator.py
parent4523beebb260d5cc283d31d842131da1851506ee (diff)
Refs #29563 -- Fixed SQLCompiler.execute_sql() to respect DatabaseFeatures.can_use_chunked_reads.
Diffstat (limited to 'tests/queries/test_iterator.py')
-rw-r--r--tests/queries/test_iterator.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/tests/queries/test_iterator.py b/tests/queries/test_iterator.py
index 56f42c2191..7fc37b00a1 100644
--- a/tests/queries/test_iterator.py
+++ b/tests/queries/test_iterator.py
@@ -1,6 +1,7 @@
import datetime
from unittest import mock
+from django.db import connections
from django.db.models.sql.compiler import cursor_iter
from django.test import TestCase
@@ -37,3 +38,15 @@ class QuerySetIteratorTests(TestCase):
self.assertEqual(cursor_iter_mock.call_count, 1)
mock_args, _mock_kwargs = cursor_iter_mock.call_args
self.assertEqual(mock_args[self.itersize_index_in_mock_args], batch_size)
+
+ def test_no_chunked_reads(self):
+ """
+ If the database backend doesn't support chunked reads, then the
+ result of SQLCompiler.execute_sql() is a list.
+ """
+ qs = Article.objects.all()
+ compiler = qs.query.get_compiler(using=qs.db)
+ features = connections[qs.db].features
+ with mock.patch.object(features, 'can_use_chunked_reads', False):
+ result = compiler.execute_sql(chunked_fetch=True)
+ self.assertIsInstance(result, list)