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
b5393028
Kaydet (Commit)
b5393028
authored
Ock 23, 2017
tarafından
orf
Kaydeden (comit)
Tim Graham
Şub 04, 2017
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fixed #27767 -- Added distinct argument to ArrayAgg.
üst
245f2091
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
25 additions
and
3 deletions
+25
-3
AUTHORS
AUTHORS
+1
-0
general.py
django/contrib/postgres/aggregates/general.py
+4
-0
aggregates.txt
docs/ref/contrib/postgres/aggregates.txt
+8
-1
2.0.txt
docs/releases/2.0.txt
+3
-1
test_aggregates.py
tests/postgres_tests/test_aggregates.py
+9
-1
No files found.
AUTHORS
Dosyayı görüntüle @
b5393028
...
@@ -756,6 +756,7 @@ answer newbie questions, and generally made Django that much better:
...
@@ -756,6 +756,7 @@ answer newbie questions, and generally made Django that much better:
tobias@neuyork.de
tobias@neuyork.de
Todd O'Bryan <toddobryan@mac.com>
Todd O'Bryan <toddobryan@mac.com>
Tom Christie <tom@tomchristie.com>
Tom Christie <tom@tomchristie.com>
Tom Forbes <tom@tomforb.es>
Tom Insam
Tom Insam
Tom Tobin
Tom Tobin
Tomáš Ehrlich <tomas.ehrlich@gmail.com>
Tomáš Ehrlich <tomas.ehrlich@gmail.com>
...
...
django/contrib/postgres/aggregates/general.py
Dosyayı görüntüle @
b5393028
...
@@ -8,6 +8,10 @@ __all__ = [
...
@@ -8,6 +8,10 @@ __all__ = [
class
ArrayAgg
(
Aggregate
):
class
ArrayAgg
(
Aggregate
):
function
=
'ARRAY_AGG'
function
=
'ARRAY_AGG'
template
=
'
%(function)
s(
%(distinct)
s
%(expressions)
s)'
def
__init__
(
self
,
expression
,
distinct
=
False
,
**
extra
):
super
()
.
__init__
(
expression
,
distinct
=
'DISTINCT '
if
distinct
else
''
,
**
extra
)
def
convert_value
(
self
,
value
,
expression
,
connection
,
context
):
def
convert_value
(
self
,
value
,
expression
,
connection
,
context
):
if
not
value
:
if
not
value
:
...
...
docs/ref/contrib/postgres/aggregates.txt
Dosyayı görüntüle @
b5393028
...
@@ -22,10 +22,17 @@ General-purpose aggregation functions
...
@@ -22,10 +22,17 @@ General-purpose aggregation functions
``ArrayAgg``
``ArrayAgg``
------------
------------
.. class:: ArrayAgg(expression, **extra)
.. class:: ArrayAgg(expression,
distinct=False,
**extra)
Returns a list of values, including nulls, concatenated into an array.
Returns a list of values, including nulls, concatenated into an array.
.. attribute:: distinct
.. versionadded:: 2.0
An optional boolean argument that determines if array values
will be distinct. Defaults to ``False``.
``BitAnd``
``BitAnd``
----------
----------
...
...
docs/releases/2.0.txt
Dosyayı görüntüle @
b5393028
...
@@ -72,7 +72,9 @@ Minor features
...
@@ -72,7 +72,9 @@ Minor features
:mod:`django.contrib.postgres`
:mod:`django.contrib.postgres`
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* ...
* The new ``distinct`` argument for
:class:`~django.contrib.postgres.aggregates.ArrayAgg` determines if
concatenated values will be distinct.
:mod:`django.contrib.redirects`
:mod:`django.contrib.redirects`
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
...
...
tests/postgres_tests/test_aggregates.py
Dosyayı görüntüle @
b5393028
...
@@ -128,7 +128,7 @@ class TestGeneralAggregate(PostgreSQLTestCase):
...
@@ -128,7 +128,7 @@ class TestGeneralAggregate(PostgreSQLTestCase):
self
.
assertEqual
(
values
,
json
.
loads
(
'{"jsonagg": []}'
))
self
.
assertEqual
(
values
,
json
.
loads
(
'{"jsonagg": []}'
))
class
Test
String
AggregateDistinct
(
PostgreSQLTestCase
):
class
TestAggregateDistinct
(
PostgreSQLTestCase
):
@classmethod
@classmethod
def
setUpTestData
(
cls
):
def
setUpTestData
(
cls
):
AggregateTestModel
.
objects
.
create
(
char_field
=
'Foo'
)
AggregateTestModel
.
objects
.
create
(
char_field
=
'Foo'
)
...
@@ -145,6 +145,14 @@ class TestStringAggregateDistinct(PostgreSQLTestCase):
...
@@ -145,6 +145,14 @@ class TestStringAggregateDistinct(PostgreSQLTestCase):
self
.
assertEqual
(
values
[
'stringagg'
]
.
count
(
'Foo'
),
1
)
self
.
assertEqual
(
values
[
'stringagg'
]
.
count
(
'Foo'
),
1
)
self
.
assertEqual
(
values
[
'stringagg'
]
.
count
(
'Bar'
),
1
)
self
.
assertEqual
(
values
[
'stringagg'
]
.
count
(
'Bar'
),
1
)
def
test_array_agg_distinct_false
(
self
):
values
=
AggregateTestModel
.
objects
.
aggregate
(
arrayagg
=
ArrayAgg
(
'char_field'
,
distinct
=
False
))
self
.
assertEqual
(
sorted
(
values
[
'arrayagg'
]),
[
'Bar'
,
'Foo'
,
'Foo'
])
def
test_array_agg_distinct_true
(
self
):
values
=
AggregateTestModel
.
objects
.
aggregate
(
arrayagg
=
ArrayAgg
(
'char_field'
,
distinct
=
True
))
self
.
assertEqual
(
sorted
(
values
[
'arrayagg'
]),
[
'Bar'
,
'Foo'
])
class
TestStatisticsAggregate
(
PostgreSQLTestCase
):
class
TestStatisticsAggregate
(
PostgreSQLTestCase
):
@classmethod
@classmethod
...
...
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