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
65858119
Kaydet (Commit)
65858119
authored
Ock 21, 2019
tarafından
Simon Charette
Kaydeden (comit)
Tim Graham
Ock 21, 2019
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fixed #30120 -- Fixed invalid SQL in distinct aggregate.
Regression in
bc05547c
(refs #28658).
üst
838e432e
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
1 deletion
+8
-1
aggregates.py
django/db/models/aggregates.py
+1
-1
tests.py
tests/aggregation/tests.py
+7
-0
No files found.
django/db/models/aggregates.py
Dosyayı görüntüle @
65858119
...
...
@@ -68,7 +68,7 @@ class Aggregate(Func):
return
[]
def
as_sql
(
self
,
compiler
,
connection
,
**
extra_context
):
extra_context
[
'distinct'
]
=
'DISTINCT'
if
self
.
distinct
else
''
extra_context
[
'distinct'
]
=
'DISTINCT
'
if
self
.
distinct
else
''
if
self
.
filter
:
if
connection
.
features
.
supports_aggregate_filter_clause
:
filter_sql
,
filter_params
=
self
.
filter
.
as_sql
(
compiler
,
connection
)
...
...
tests/aggregation/tests.py
Dosyayı görüntüle @
65858119
...
...
@@ -8,6 +8,7 @@ from django.db.models import (
Avg
,
Count
,
DecimalField
,
DurationField
,
F
,
FloatField
,
Func
,
IntegerField
,
Max
,
Min
,
Sum
,
Value
,
)
from
django.db.models.expressions
import
Case
,
When
from
django.test
import
TestCase
from
django.test.utils
import
Approximate
,
CaptureQueriesContext
from
django.utils
import
timezone
...
...
@@ -395,6 +396,12 @@ class AggregateTestCase(TestCase):
sql
=
ctx
.
captured_queries
[
0
][
'sql'
]
self
.
assertIn
(
'SELECT COUNT(*) '
,
sql
)
def
test_count_distinct_expression
(
self
):
aggs
=
Book
.
objects
.
aggregate
(
distinct_ratings
=
Count
(
Case
(
When
(
pages__gt
=
300
,
then
=
'rating'
)),
distinct
=
True
),
)
self
.
assertEqual
(
aggs
[
'distinct_ratings'
],
4
)
def
test_non_grouped_annotation_not_in_group_by
(
self
):
"""
An annotation not included in values() before an aggregate should be
...
...
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