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
ac5f886c
Kaydet (Commit)
ac5f886c
authored
Ock 31, 2017
tarafından
Lex Berezhny
Kaydeden (comit)
Tim Graham
Ock 31, 2017
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fixed #27800 -- Fixed QuerySet.annotate(Length(...)).distinct() crash.
üst
84126f27
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
13 additions
and
2 deletions
+13
-2
AUTHORS
AUTHORS
+1
-0
query.py
django/db/models/sql/query.py
+6
-1
tests.py
tests/annotations/tests.py
+6
-1
No files found.
AUTHORS
Dosyayı görüntüle @
ac5f886c
...
...
@@ -456,6 +456,7 @@ answer newbie questions, and generally made Django that much better:
Leo Shklovskii
Leo Soto <leo.soto@gmail.com>
lerouxb@gmail.com
Lex Berezhny <lex@damoti.com>
Liang Feng <hutuworm@gmail.com>
limodou
Loek van Gent <loek@barakken.nl>
...
...
django/db/models/sql/query.py
Dosyayı görüntüle @
ac5f886c
...
...
@@ -1329,7 +1329,12 @@ class Query:
"querying. If it is a GenericForeignKey, consider "
"adding a GenericRelation."
%
name
)
model
=
field
.
model
.
_meta
.
concrete_model
try
:
model
=
field
.
model
.
_meta
.
concrete_model
except
AttributeError
:
# QuerySet.annotate() may introduce fields that aren't
# attached to a model.
model
=
None
else
:
# We didn't find the current field, so move position back
# one step.
...
...
tests/annotations/tests.py
Dosyayı görüntüle @
ac5f886c
...
...
@@ -6,7 +6,7 @@ from django.db.models import (
BooleanField
,
CharField
,
Count
,
DateTimeField
,
ExpressionWrapper
,
F
,
Func
,
IntegerField
,
NullBooleanField
,
Q
,
Sum
,
Value
,
)
from
django.db.models.functions
import
Lower
from
django.db.models.functions
import
L
ength
,
L
ower
from
django.test
import
TestCase
,
skipUnlessDBFeature
from
.models
import
(
...
...
@@ -205,6 +205,11 @@ class NonAggregateAnnotationTestCase(TestCase):
)
.
distinct
(
'test_alias'
)
self
.
assertEqual
(
len
(
people2
),
1
)
lengths
=
Employee
.
objects
.
annotate
(
name_len
=
Length
(
'first_name'
),
)
.
distinct
(
'name_len'
)
.
values_list
(
'name_len'
,
flat
=
True
)
self
.
assertSequenceEqual
(
lengths
,
[
3
,
7
,
8
])
def
test_filter_annotation
(
self
):
books
=
Book
.
objects
.
annotate
(
is_book
=
Value
(
1
,
output_field
=
IntegerField
())
...
...
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