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
fbf64728
Kaydet (Commit)
fbf64728
authored
Ock 03, 2018
tarafından
Robin Ramael
Kaydeden (comit)
Tim Graham
Ock 03, 2018
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fixed #28811 -- Fixed crash when combining regular and group by annotations.
üst
2cb6b773
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
1 deletion
+19
-1
query.py
django/db/models/sql/query.py
+1
-1
tests.py
tests/annotations/tests.py
+18
-0
No files found.
django/db/models/sql/query.py
Dosyayı görüntüle @
fbf64728
...
...
@@ -1514,7 +1514,7 @@ class Query:
# that case we need to return a Ref to the subquery's annotation.
return
Ref
(
name
,
self
.
annotation_select
[
name
])
else
:
return
self
.
annotation
_select
[
name
]
return
self
.
annotation
s
[
name
]
else
:
field_list
=
name
.
split
(
LOOKUP_SEP
)
join_info
=
self
.
setup_joins
(
field_list
,
self
.
get_meta
(),
self
.
get_initial_alias
(),
can_reuse
=
reuse
)
...
...
tests/annotations/tests.py
Dosyayı görüntüle @
fbf64728
...
...
@@ -527,6 +527,24 @@ class NonAggregateAnnotationTestCase(TestCase):
self
.
assertIs
(
book
.
is_pony
,
False
)
self
.
assertIsNone
(
book
.
is_none
)
def
test_annotation_in_f_grouped_by_annotation
(
self
):
qs
=
(
Publisher
.
objects
.
annotate
(
multiplier
=
Value
(
3
))
# group by option => sum of value * multiplier
.
values
(
'name'
)
.
annotate
(
multiplied_value_sum
=
Sum
(
F
(
'multiplier'
)
*
F
(
'num_awards'
)))
.
order_by
()
)
self
.
assertCountEqual
(
qs
,
[
{
'multiplied_value_sum'
:
9
,
'name'
:
'Apress'
},
{
'multiplied_value_sum'
:
0
,
'name'
:
"Jonno's House of Books"
},
{
'multiplied_value_sum'
:
27
,
'name'
:
'Morgan Kaufmann'
},
{
'multiplied_value_sum'
:
21
,
'name'
:
'Prentice Hall'
},
{
'multiplied_value_sum'
:
3
,
'name'
:
'Sams'
},
]
)
def
test_arguments_must_be_expressions
(
self
):
msg
=
'QuerySet.annotate() received non-expression(s):
%
s.'
with
self
.
assertRaisesMessage
(
TypeError
,
msg
%
BooleanField
()):
...
...
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