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
bb0b6e52
Kaydet (Commit)
bb0b6e52
authored
May 18, 2017
tarafından
Tom
Kaydeden (comit)
Tim Graham
May 25, 2017
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fixed #28211 -- Prevented ORing an empty Q() from reducing query join efficiency.
üst
1c3a6cec
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
0 deletions
+17
-0
query_utils.py
django/db/models/query_utils.py
+9
-0
test_q.py
tests/queries/test_q.py
+8
-0
No files found.
django/db/models/query_utils.py
Dosyayı görüntüle @
bb0b6e52
...
@@ -5,6 +5,7 @@ Factored out from django.db.models.query to avoid making the main module very
...
@@ -5,6 +5,7 @@ Factored out from django.db.models.query to avoid making the main module very
large and/or so that they can be used by other modules without getting into
large and/or so that they can be used by other modules without getting into
circular import difficulties.
circular import difficulties.
"""
"""
import
copy
import
functools
import
functools
import
inspect
import
inspect
from
collections
import
namedtuple
from
collections
import
namedtuple
...
@@ -61,6 +62,14 @@ class Q(tree.Node):
...
@@ -61,6 +62,14 @@ class Q(tree.Node):
def
_combine
(
self
,
other
,
conn
):
def
_combine
(
self
,
other
,
conn
):
if
not
isinstance
(
other
,
Q
):
if
not
isinstance
(
other
,
Q
):
raise
TypeError
(
other
)
raise
TypeError
(
other
)
# If the other Q() is empty, ignore it and just use `self`.
if
not
other
:
return
copy
.
deepcopy
(
self
)
# Or if this Q is empty, ignore it and just use `other`.
elif
not
self
:
return
copy
.
deepcopy
(
other
)
obj
=
type
(
self
)()
obj
=
type
(
self
)()
obj
.
connector
=
conn
obj
.
connector
=
conn
obj
.
add
(
self
,
conn
)
obj
.
add
(
self
,
conn
)
...
...
tests/queries/test_q.py
Dosyayı görüntüle @
bb0b6e52
...
@@ -11,6 +11,14 @@ class QTests(SimpleTestCase):
...
@@ -11,6 +11,14 @@ class QTests(SimpleTestCase):
def
test_combine_and_both_empty
(
self
):
def
test_combine_and_both_empty
(
self
):
self
.
assertEqual
(
Q
()
&
Q
(),
Q
())
self
.
assertEqual
(
Q
()
&
Q
(),
Q
())
def
test_combine_or_empty
(
self
):
q
=
Q
(
x
=
1
)
self
.
assertEqual
(
q
|
Q
(),
q
)
self
.
assertEqual
(
Q
()
|
q
,
q
)
def
test_combine_or_both_empty
(
self
):
self
.
assertEqual
(
Q
()
|
Q
(),
Q
())
def
test_deconstruct
(
self
):
def
test_deconstruct
(
self
):
q
=
Q
(
price__gt
=
F
(
'discounted_price'
))
q
=
Q
(
price__gt
=
F
(
'discounted_price'
))
path
,
args
,
kwargs
=
q
.
deconstruct
()
path
,
args
,
kwargs
=
q
.
deconstruct
()
...
...
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