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
cdfdcf4b
Kaydet (Commit)
cdfdcf4b
authored
Agu 10, 2014
tarafından
Anubhav Joshi
Kaydeden (comit)
Anssi Kääriäinen
Agu 11, 2014
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fixed #23266 -- Prevented queries caused by type checking lookup values
Small modifications done by committer.
üst
f0b35888
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
2 deletions
+17
-2
query.py
django/db/models/sql/query.py
+13
-2
tests.py
tests/queries/tests.py
+4
-0
No files found.
django/db/models/sql/query.py
Dosyayı görüntüle @
cdfdcf4b
...
@@ -1104,8 +1104,19 @@ class Query(object):
...
@@ -1104,8 +1104,19 @@ class Query(object):
if
field
.
rel
:
if
field
.
rel
:
# testing for iterable of models
# testing for iterable of models
if
hasattr
(
value
,
'__iter__'
):
if
hasattr
(
value
,
'__iter__'
):
for
v
in
value
:
# Check if the iterable has a model attribute, if so
self
.
check_query_object_type
(
v
,
opts
)
# it is likely something like a QuerySet.
if
hasattr
(
value
,
'model'
)
and
hasattr
(
value
.
model
,
'_meta'
):
model
=
value
.
model
if
not
(
model
==
opts
.
concrete_model
or
opts
.
concrete_model
in
model
.
_meta
.
get_parent_list
()
or
model
in
opts
.
get_parent_list
()):
raise
ValueError
(
'Cannot use QuerySet for "
%
s": Use a QuerySet for "
%
s".'
%
(
model
.
_meta
.
model_name
,
opts
.
object_name
))
else
:
for
v
in
value
:
self
.
check_query_object_type
(
v
,
opts
)
else
:
else
:
# expecting single model instance here
# expecting single model instance here
self
.
check_query_object_type
(
value
,
opts
)
self
.
check_query_object_type
(
value
,
opts
)
...
...
tests/queries/tests.py
Dosyayı görüntüle @
cdfdcf4b
...
@@ -3461,6 +3461,10 @@ class RelatedLookupTypeTests(TestCase):
...
@@ -3461,6 +3461,10 @@ class RelatedLookupTypeTests(TestCase):
# parent objects
# parent objects
self
.
assertQuerysetEqual
(
ObjectC
.
objects
.
exclude
(
childobjecta
=
self
.
oa
),
out_c
)
self
.
assertQuerysetEqual
(
ObjectC
.
objects
.
exclude
(
childobjecta
=
self
.
oa
),
out_c
)
# Test for #23226
with
self
.
assertNumQueries
(
0
):
ObjectB
.
objects
.
filter
(
objecta__in
=
ObjectA
.
objects
.
all
())
class
Ticket14056Tests
(
TestCase
):
class
Ticket14056Tests
(
TestCase
):
def
test_ticket_14056
(
self
):
def
test_ticket_14056
(
self
):
...
...
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