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
aa2cb4c6
Kaydet (Commit)
aa2cb4c6
authored
Kas 12, 2016
tarafından
Mads Jensen
Kaydeden (comit)
Tim Graham
Kas 28, 2016
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Refs #26327 -- Renamed JsonAgg to JSONBAgg.
Thanks to Christian von Roques for the report.
üst
6252fd63
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
16 additions
and
12 deletions
+16
-12
general.py
django/contrib/postgres/aggregates/general.py
+2
-2
features.py
django/db/backends/postgresql/features.py
+4
-0
aggregates.txt
docs/ref/contrib/postgres/aggregates.txt
+4
-4
1.11.txt
docs/releases/1.11.txt
+1
-1
test_aggregates.py
tests/postgres_tests/test_aggregates.py
+5
-5
No files found.
django/contrib/postgres/aggregates/general.py
Dosyayı görüntüle @
aa2cb4c6
...
...
@@ -2,7 +2,7 @@ from django.contrib.postgres.fields import JSONField
from
django.db.models.aggregates
import
Aggregate
__all__
=
[
'ArrayAgg'
,
'BitAnd'
,
'BitOr'
,
'BoolAnd'
,
'BoolOr'
,
'J
son
Agg'
,
'StringAgg'
,
'ArrayAgg'
,
'BitAnd'
,
'BitOr'
,
'BoolAnd'
,
'BoolOr'
,
'J
SONB
Agg'
,
'StringAgg'
,
]
...
...
@@ -31,7 +31,7 @@ class BoolOr(Aggregate):
function
=
'BOOL_OR'
class
J
son
Agg
(
Aggregate
):
class
J
SONB
Agg
(
Aggregate
):
function
=
'JSONB_AGG'
_output_field
=
JSONField
()
...
...
django/db/backends/postgresql/features.py
Dosyayı görüntüle @
aa2cb4c6
...
...
@@ -40,3 +40,7 @@ class DatabaseFeatures(BaseDatabaseFeatures):
@cached_property
def
has_jsonb_datatype
(
self
):
return
self
.
connection
.
pg_version
>=
90400
@cached_property
def
has_jsonb_agg
(
self
):
return
self
.
connection
.
pg_version
>=
90500
docs/ref/contrib/postgres/aggregates.txt
Dosyayı görüntüle @
aa2cb4c6
...
...
@@ -58,14 +58,14 @@ General-purpose aggregation functions
Returns ``True`` if at least one input value is true, ``None`` if all
values are null or if there are no values, otherwise ``False``.
``J
son
Agg``
-----------
``J
SONB
Agg``
-----------
-
.. class:: J
son
Agg(expressions, **extra)
.. class:: J
SONB
Agg(expressions, **extra)
.. versionadded:: 1.11
Returns the input values as a ``JSON`` array.
Returns the input values as a ``JSON`` array.
Requires PostgreSQL ≥ 9.5.
``StringAgg``
-------------
...
...
docs/releases/1.11.txt
Dosyayı görüntüle @
aa2cb4c6
...
...
@@ -183,7 +183,7 @@ Minor features
operation allow using PostgreSQL's ``citext`` extension for case-insensitive
lookups.
* The new :class:`~django.contrib.postgres.aggregates.J
son
Agg` allows
* The new :class:`~django.contrib.postgres.aggregates.J
SONB
Agg` allows
aggregating values as a JSON array.
:mod:`django.contrib.redirects`
...
...
tests/postgres_tests/test_aggregates.py
Dosyayı görüntüle @
aa2cb4c6
...
...
@@ -9,7 +9,7 @@ from .models import AggregateTestModel, StatTestModel
try
:
from
django.contrib.postgres.aggregates
import
(
ArrayAgg
,
BitAnd
,
BitOr
,
BoolAnd
,
BoolOr
,
Corr
,
CovarPop
,
J
son
Agg
,
ArrayAgg
,
BitAnd
,
BitOr
,
BoolAnd
,
BoolOr
,
Corr
,
CovarPop
,
J
SONB
Agg
,
RegrAvgX
,
RegrAvgY
,
RegrCount
,
RegrIntercept
,
RegrR2
,
RegrSlope
,
RegrSXX
,
RegrSXY
,
RegrSYY
,
StatAggregate
,
StringAgg
,
)
...
...
@@ -117,14 +117,14 @@ class TestGeneralAggregate(PostgreSQLTestCase):
values
=
AggregateTestModel
.
objects
.
aggregate
(
stringagg
=
StringAgg
(
'char_field'
,
delimiter
=
';'
))
self
.
assertEqual
(
values
,
{
'stringagg'
:
''
})
@skipUnlessDBFeature
(
'has_jsonb_
datatype
'
)
@skipUnlessDBFeature
(
'has_jsonb_
agg
'
)
def
test_json_agg
(
self
):
values
=
AggregateTestModel
.
objects
.
aggregate
(
jsonagg
=
J
son
Agg
(
'char_field'
))
values
=
AggregateTestModel
.
objects
.
aggregate
(
jsonagg
=
J
SONB
Agg
(
'char_field'
))
self
.
assertEqual
(
values
,
{
'jsonagg'
:
[
'Foo1'
,
'Foo2'
,
'Foo3'
,
'Foo4'
]})
@skipUnlessDBFeature
(
'has_jsonb_
datatype
'
)
@skipUnlessDBFeature
(
'has_jsonb_
agg
'
)
def
test_json_agg_empty
(
self
):
values
=
AggregateTestModel
.
objects
.
none
()
.
aggregate
(
jsonagg
=
J
son
Agg
(
'integer_field'
))
values
=
AggregateTestModel
.
objects
.
none
()
.
aggregate
(
jsonagg
=
J
SONB
Agg
(
'integer_field'
))
self
.
assertEqual
(
values
,
json
.
loads
(
'{"jsonagg": []}'
))
...
...
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