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
0e64e046
Unverified
Kaydet (Commit)
0e64e046
authored
Tem 02, 2018
tarafından
Mariusz Felisiak
Kaydeden (comit)
GitHub
Tem 02, 2018
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fixed #29530 -- Fixed aliases ordering when chaining annotate() and filter().
üst
b49b59b0
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
2 deletions
+24
-2
query.py
django/db/models/sql/query.py
+8
-2
tests.py
tests/annotations/tests.py
+16
-0
No files found.
django/db/models/sql/query.py
Dosyayı görüntüle @
0e64e046
...
...
@@ -934,8 +934,14 @@ class Query:
if
(
reuse
is
None
or
a
in
reuse
)
and
j
==
join
]
if
reuse_aliases
:
self
.
ref_alias
(
reuse_aliases
[
0
])
return
reuse_aliases
[
0
]
if
join
.
table_alias
in
reuse_aliases
:
reuse_alias
=
join
.
table_alias
else
:
# Reuse the most recent alias of the joined table
# (a many-to-many relation may be joined multiple times).
reuse_alias
=
reuse_aliases
[
-
1
]
self
.
ref_alias
(
reuse_alias
)
return
reuse_alias
# No reuse is possible, so we need a new alias.
alias
,
_
=
self
.
table_alias
(
join
.
table_name
,
create
=
True
,
filtered_relation
=
join
.
filtered_relation
)
...
...
tests/annotations/tests.py
Dosyayı görüntüle @
0e64e046
...
...
@@ -569,3 +569,19 @@ class NonAggregateAnnotationTestCase(TestCase):
Book
.
objects
.
annotate
(
is_book
=
True
)
with
self
.
assertRaisesMessage
(
TypeError
,
msg
%
', '
.
join
([
str
(
BooleanField
()),
'True'
])):
Book
.
objects
.
annotate
(
BooleanField
(),
Value
(
False
),
is_book
=
True
)
def
test_chaining_annotation_filter_with_m2m
(
self
):
qs
=
Author
.
objects
.
filter
(
name
=
'Adrian Holovaty'
,
friends__age
=
35
,
)
.
annotate
(
jacob_name
=
F
(
'friends__name'
),
)
.
filter
(
friends__age
=
29
,
)
.
annotate
(
james_name
=
F
(
'friends__name'
),
)
.
values
(
'jacob_name'
,
'james_name'
)
self
.
assertCountEqual
(
qs
,
[{
'jacob_name'
:
'Jacob Kaplan-Moss'
,
'james_name'
:
'James Bennett'
}],
)
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