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
f19a4945
Kaydet (Commit)
f19a4945
authored
Mar 08, 2019
tarafından
Simon Charette
Kaydeden (comit)
Tim Graham
Mar 23, 2019
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fixed #21703 -- Fixed a crash when excluding a related field with a F().
üst
cbf7e715
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
1 deletion
+12
-1
query.py
django/db/models/sql/query.py
+6
-1
tests.py
tests/queries/tests.py
+6
-0
No files found.
django/db/models/sql/query.py
Dosyayı görüntüle @
f19a4945
...
...
@@ -21,7 +21,9 @@ from django.core.exceptions import (
from
django.db
import
DEFAULT_DB_ALIAS
,
NotSupportedError
,
connections
from
django.db.models.aggregates
import
Count
from
django.db.models.constants
import
LOOKUP_SEP
from
django.db.models.expressions
import
BaseExpression
,
Col
,
F
,
Ref
,
SimpleCol
from
django.db.models.expressions
import
(
BaseExpression
,
Col
,
F
,
OuterRef
,
Ref
,
SimpleCol
,
)
from
django.db.models.fields
import
Field
from
django.db.models.fields.related_lookups
import
MultiColSource
from
django.db.models.lookups
import
Lookup
...
...
@@ -1639,6 +1641,9 @@ class Query(BaseExpression):
saner null handling, and is easier for the backend's optimizer to
handle.
"""
filter_lhs
,
filter_rhs
=
filter_expr
if
isinstance
(
filter_rhs
,
F
):
filter_expr
=
(
filter_lhs
,
OuterRef
(
filter_rhs
.
name
))
# Generate the inner query.
query
=
Query
(
self
.
model
)
query
.
add_filter
(
filter_expr
)
...
...
tests/queries/tests.py
Dosyayı görüntüle @
f19a4945
...
...
@@ -2776,6 +2776,12 @@ class ExcludeTests(TestCase):
employment__title__in
=
(
'Engineer'
,
'Developer'
))
.
distinct
()
.
order_by
(
'name'
)
self
.
assertSequenceEqual
(
alex_nontech_employers
,
[
google
,
intel
,
microsoft
])
def
test_exclude_reverse_fk_field_ref
(
self
):
tag
=
Tag
.
objects
.
create
()
Note
.
objects
.
create
(
tag
=
tag
,
note
=
'note'
)
annotation
=
Annotation
.
objects
.
create
(
name
=
'annotation'
,
tag
=
tag
)
self
.
assertEqual
(
Annotation
.
objects
.
exclude
(
tag__note__note
=
F
(
'name'
))
.
get
(),
annotation
)
class
ExcludeTest17600
(
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