Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
D
django
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
django
Commits
55810d94
Kaydet (Commit)
55810d94
authored
Tem 20, 2018
tarafından
Andrew Brown
Kaydeden (comit)
Tim Graham
Tem 25, 2018
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Refs #29563 -- Fixed SQLCompiler.execute_sql() to respect DatabaseFeatures.can_use_chunked_reads.
üst
4523beeb
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
2 deletions
+16
-2
compiler.py
django/db/models/sql/compiler.py
+3
-2
test_iterator.py
tests/queries/test_iterator.py
+13
-0
No files found.
django/db/models/sql/compiler.py
Dosyayı görüntüle @
55810d94
...
...
@@ -1089,11 +1089,12 @@ class SQLCompiler:
self
.
col_count
if
self
.
has_extra_select
else
None
,
chunk_size
,
)
if
not
chunked_fetch
and
not
self
.
connection
.
features
.
can_use_chunked_reads
:
if
not
chunked_fetch
or
not
self
.
connection
.
features
.
can_use_chunked_reads
:
try
:
# If we are using non-chunked reads, we return the same data
# structure as normally, but ensure it is all read into memory
# before going any further. Use chunked_fetch if requested.
# before going any further. Use chunked_fetch if requested,
# unless the database doesn't support it.
return
list
(
result
)
finally
:
# done with the cursor
...
...
tests/queries/test_iterator.py
Dosyayı görüntüle @
55810d94
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
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment