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
d6381d35
Kaydet (Commit)
d6381d35
authored
Ock 05, 2018
tarafından
Nick Pope
Kaydeden (comit)
Tim Graham
Agu 02, 2018
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fixed #28990 -- Added autosummarize parameter to BrinIndex.
üst
4c36e9e4
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
45 additions
and
4 deletions
+45
-4
indexes.py
django/contrib/postgres/indexes.py
+6
-1
features.py
django/db/backends/postgresql/features.py
+5
-0
indexes.txt
docs/ref/contrib/postgres/indexes.txt
+10
-1
2.2.txt
docs/releases/2.2.txt
+3
-0
spelling_wordlist
docs/spelling_wordlist
+1
-0
test_indexes.py
tests/postgres_tests/test_indexes.py
+20
-2
No files found.
django/contrib/postgres/indexes.py
Dosyayı görüntüle @
d6381d35
...
@@ -31,20 +31,25 @@ class PostgresIndex(Index):
...
@@ -31,20 +31,25 @@ class PostgresIndex(Index):
class
BrinIndex
(
PostgresIndex
):
class
BrinIndex
(
PostgresIndex
):
suffix
=
'brin'
suffix
=
'brin'
def
__init__
(
self
,
*
,
pages_per_range
=
None
,
**
kwargs
):
def
__init__
(
self
,
*
,
autosummarize
=
None
,
pages_per_range
=
None
,
**
kwargs
):
if
pages_per_range
is
not
None
and
pages_per_range
<=
0
:
if
pages_per_range
is
not
None
and
pages_per_range
<=
0
:
raise
ValueError
(
'pages_per_range must be None or a positive integer'
)
raise
ValueError
(
'pages_per_range must be None or a positive integer'
)
self
.
autosummarize
=
autosummarize
self
.
pages_per_range
=
pages_per_range
self
.
pages_per_range
=
pages_per_range
super
()
.
__init__
(
**
kwargs
)
super
()
.
__init__
(
**
kwargs
)
def
deconstruct
(
self
):
def
deconstruct
(
self
):
path
,
args
,
kwargs
=
super
()
.
deconstruct
()
path
,
args
,
kwargs
=
super
()
.
deconstruct
()
if
self
.
autosummarize
is
not
None
:
kwargs
[
'autosummarize'
]
=
self
.
autosummarize
if
self
.
pages_per_range
is
not
None
:
if
self
.
pages_per_range
is
not
None
:
kwargs
[
'pages_per_range'
]
=
self
.
pages_per_range
kwargs
[
'pages_per_range'
]
=
self
.
pages_per_range
return
path
,
args
,
kwargs
return
path
,
args
,
kwargs
def
get_with_params
(
self
):
def
get_with_params
(
self
):
with_params
=
[]
with_params
=
[]
if
self
.
autosummarize
is
not
None
:
with_params
.
append
(
'autosummarize =
%
s'
%
(
'on'
if
self
.
autosummarize
else
'off'
))
if
self
.
pages_per_range
is
not
None
:
if
self
.
pages_per_range
is
not
None
:
with_params
.
append
(
'pages_per_range =
%
d'
%
self
.
pages_per_range
)
with_params
.
append
(
'pages_per_range =
%
d'
%
self
.
pages_per_range
)
return
with_params
return
with_params
...
...
django/db/backends/postgresql/features.py
Dosyayı görüntüle @
d6381d35
...
@@ -57,7 +57,12 @@ class DatabaseFeatures(BaseDatabaseFeatures):
...
@@ -57,7 +57,12 @@ class DatabaseFeatures(BaseDatabaseFeatures):
def
is_postgresql_9_5
(
self
):
def
is_postgresql_9_5
(
self
):
return
self
.
connection
.
pg_version
>=
90500
return
self
.
connection
.
pg_version
>=
90500
@cached_property
def
is_postgresql_10
(
self
):
return
self
.
connection
.
pg_version
>=
100000
has_select_for_update_skip_locked
=
is_postgresql_9_5
has_select_for_update_skip_locked
=
is_postgresql_9_5
has_brin_index_support
=
is_postgresql_9_5
has_brin_index_support
=
is_postgresql_9_5
has_jsonb_agg
=
is_postgresql_9_5
has_jsonb_agg
=
is_postgresql_9_5
has_brin_autosummarize
=
is_postgresql_10
has_gin_pending_list_limit
=
is_postgresql_9_5
has_gin_pending_list_limit
=
is_postgresql_9_5
docs/ref/contrib/postgres/indexes.txt
Dosyayı görüntüle @
d6381d35
...
@@ -10,13 +10,22 @@ available from the ``django.contrib.postgres.indexes`` module.
...
@@ -10,13 +10,22 @@ available from the ``django.contrib.postgres.indexes`` module.
``BrinIndex``
``BrinIndex``
=============
=============
.. class:: BrinIndex(pages_per_range=None, **options)
.. class:: BrinIndex(
autosummarize=None,
pages_per_range=None, **options)
Creates a `BRIN index
Creates a `BRIN index
<https://www.postgresql.org/docs/current/static/brin-intro.html>`_.
<https://www.postgresql.org/docs/current/static/brin-intro.html>`_.
Set the ``autosummarize`` parameter to ``True`` to enable `automatic
summarization`_ to be performed by autovacuum.
The ``pages_per_range`` argument takes a positive integer.
The ``pages_per_range`` argument takes a positive integer.
.. _automatic summarization: https://www.postgresql.org/docs/current/static/brin-intro.html#BRIN-OPERATION
.. versionchanged:: 2.2
The ``autosummarize`` parameter was added.
``GinIndex``
``GinIndex``
============
============
...
...
docs/releases/2.2.txt
Dosyayı görüntüle @
d6381d35
...
@@ -86,6 +86,9 @@ Minor features
...
@@ -86,6 +86,9 @@ Minor features
:class:`~django.contrib.postgres.indexes.SpGistIndex` classes allow
:class:`~django.contrib.postgres.indexes.SpGistIndex` classes allow
creating ``hash`` and ``SP-GiST`` indexes in the database.
creating ``hash`` and ``SP-GiST`` indexes in the database.
* :class:`~django.contrib.postgres.indexes.BrinIndex` now has the
``autosummarize`` parameter.
:mod:`django.contrib.redirects`
:mod:`django.contrib.redirects`
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
...
...
docs/spelling_wordlist
Dosyayı görüntüle @
d6381d35
...
@@ -42,6 +42,7 @@ autoextend
...
@@ -42,6 +42,7 @@ autoextend
autogenerated
autogenerated
autoincrement
autoincrement
autoreload
autoreload
autovacuum
Azerbaijani
Azerbaijani
backend
backend
backends
backends
...
...
tests/postgres_tests/test_indexes.py
Dosyayı görüntüle @
d6381d35
...
@@ -31,11 +31,16 @@ class BrinIndexTests(IndexTestMixin, PostgreSQLTestCase):
...
@@ -31,11 +31,16 @@ class BrinIndexTests(IndexTestMixin, PostgreSQLTestCase):
self
.
assertEqual
(
BrinIndex
.
suffix
,
'brin'
)
self
.
assertEqual
(
BrinIndex
.
suffix
,
'brin'
)
def
test_deconstruction
(
self
):
def
test_deconstruction
(
self
):
index
=
BrinIndex
(
fields
=
[
'title'
],
name
=
'test_title_brin'
,
pages_per_range
=
16
)
index
=
BrinIndex
(
fields
=
[
'title'
],
name
=
'test_title_brin'
,
autosummarize
=
True
,
pages_per_range
=
16
)
path
,
args
,
kwargs
=
index
.
deconstruct
()
path
,
args
,
kwargs
=
index
.
deconstruct
()
self
.
assertEqual
(
path
,
'django.contrib.postgres.indexes.BrinIndex'
)
self
.
assertEqual
(
path
,
'django.contrib.postgres.indexes.BrinIndex'
)
self
.
assertEqual
(
args
,
())
self
.
assertEqual
(
args
,
())
self
.
assertEqual
(
kwargs
,
{
'fields'
:
[
'title'
],
'name'
:
'test_title_brin'
,
'pages_per_range'
:
16
})
self
.
assertEqual
(
kwargs
,
{
'fields'
:
[
'title'
],
'name'
:
'test_title_brin'
,
'autosummarize'
:
True
,
'pages_per_range'
:
16
,
})
def
test_invalid_pages_per_range
(
self
):
def
test_invalid_pages_per_range
(
self
):
with
self
.
assertRaisesMessage
(
ValueError
,
'pages_per_range must be None or a positive integer'
):
with
self
.
assertRaisesMessage
(
ValueError
,
'pages_per_range must be None or a positive integer'
):
...
@@ -176,6 +181,19 @@ class SchemaTests(PostgreSQLTestCase):
...
@@ -176,6 +181,19 @@ class SchemaTests(PostgreSQLTestCase):
editor
.
remove_index
(
CharFieldModel
,
index
)
editor
.
remove_index
(
CharFieldModel
,
index
)
self
.
assertNotIn
(
index_name
,
self
.
get_constraints
(
CharFieldModel
.
_meta
.
db_table
))
self
.
assertNotIn
(
index_name
,
self
.
get_constraints
(
CharFieldModel
.
_meta
.
db_table
))
@skipUnlessDBFeature
(
'has_brin_index_support'
,
'has_brin_autosummarize'
)
def
test_brin_parameters
(
self
):
index_name
=
'char_field_brin_params'
index
=
BrinIndex
(
fields
=
[
'field'
],
name
=
index_name
,
autosummarize
=
True
)
with
connection
.
schema_editor
()
as
editor
:
editor
.
add_index
(
CharFieldModel
,
index
)
constraints
=
self
.
get_constraints
(
CharFieldModel
.
_meta
.
db_table
)
self
.
assertEqual
(
constraints
[
index_name
][
'type'
],
BrinIndex
.
suffix
)
self
.
assertEqual
(
constraints
[
index_name
][
'options'
],
[
'autosummarize=on'
])
with
connection
.
schema_editor
()
as
editor
:
editor
.
remove_index
(
CharFieldModel
,
index
)
self
.
assertNotIn
(
index_name
,
self
.
get_constraints
(
CharFieldModel
.
_meta
.
db_table
))
def
test_gist_index
(
self
):
def
test_gist_index
(
self
):
# Ensure the table is there and doesn't have an index.
# Ensure the table is there and doesn't have an index.
self
.
assertNotIn
(
'field'
,
self
.
get_constraints
(
CharFieldModel
.
_meta
.
db_table
))
self
.
assertNotIn
(
'field'
,
self
.
get_constraints
(
CharFieldModel
.
_meta
.
db_table
))
...
...
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