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
5e2c4d7a
Kaydet (Commit)
5e2c4d7a
authored
Şub 26, 2016
tarafından
Attila Tovt
Kaydeden (comit)
Tim Graham
Şub 27, 2016
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fixed #26264 -- Fixed prefetch_related() crashes with values_list(flat=True)
üst
3389c5ea
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
5 deletions
+17
-5
query.py
django/db/models/query.py
+6
-5
test_uuid.py
tests/prefetch_related/test_uuid.py
+11
-0
No files found.
django/db/models/query.py
Dosyayı görüntüle @
5e2c4d7a
...
...
@@ -1421,11 +1421,12 @@ def prefetch_related_objects(model_instances, *related_lookups):
if
not
hasattr
(
obj
,
'_prefetched_objects_cache'
):
try
:
obj
.
_prefetched_objects_cache
=
{}
except
AttributeError
:
# Must be in a QuerySet subclass that is not returning
# Model instances, either in Django or 3rd
# party. prefetch_related() doesn't make sense, so quit
# now.
except
(
AttributeError
,
TypeError
):
# Must be an immutable object from
# values_list(flat=True), for example (TypeError) or
# a QuerySet subclass that isn't returning Model
# instances (AttributeError), either in Django or a 3rd
# party. prefetch_related() doesn't make sense, so quit.
good_objects
=
False
break
if
not
good_objects
:
...
...
tests/prefetch_related/test_uuid.py
Dosyayı görüntüle @
5e2c4d7a
...
...
@@ -44,6 +44,17 @@ class UUIDPrefetchRelated(TestCase):
with
self
.
assertNumQueries
(
0
):
self
.
assertEqual
(
2
,
len
(
flea
.
pets_visited
.
all
()))
def
test_prefetch_related_from_uuid_model_to_uuid_model_with_values_flat
(
self
):
pet
=
Pet
.
objects
.
create
(
name
=
'Fifi'
)
pet
.
people
.
add
(
Person
.
objects
.
create
(
name
=
'Ellen'
),
Person
.
objects
.
create
(
name
=
'George'
),
)
self
.
assertSequenceEqual
(
Pet
.
objects
.
prefetch_related
(
'fleas_hosted'
)
.
values_list
(
'id'
,
flat
=
True
),
[
pet
.
id
]
)
class
UUIDPrefetchRelatedLookups
(
TestCase
):
...
...
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