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
3a5299c1
Kaydet (Commit)
3a5299c1
authored
May 12, 2017
tarafından
Tim Schneider
Kaydeden (comit)
Tim Graham
May 15, 2017
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fixed #28197 -- Fixed introspection of index field ordering on PostgreSQL.
üst
3008f30f
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
16 additions
and
4 deletions
+16
-4
introspection.py
django/db/backends/postgresql/introspection.py
+7
-3
1.11.2.txt
docs/releases/1.11.2.txt
+2
-0
models.py
tests/introspection/models.py
+1
-0
tests.py
tests/introspection/tests.py
+6
-1
No files found.
django/db/backends/postgresql/introspection.py
Dosyayı görüntüle @
3a5299c1
...
...
@@ -191,13 +191,17 @@ class DatabaseIntrospection(BaseDatabaseIntrospection):
"options"
:
options
,
}
# Now get indexes
# The row_number() function for ordering the index fields can be
# replaced by WITH ORDINALITY in the unnest() functions when support
# for PostgreSQL 9.3 is dropped.
cursor
.
execute
(
"""
SELECT
indexname, array_agg(attname), indisunique, indisprimary,
array_agg(ordering), amname, exprdef, s2.attoptions
indexname, array_agg(attname
ORDER BY rnum
), indisunique, indisprimary,
array_agg(ordering
ORDER BY rnum
), amname, exprdef, s2.attoptions
FROM (
SELECT
c2.relname as indexname, idx.*, attr.attname, am.amname,
row_number() OVER () as rnum, c2.relname as indexname,
idx.*, attr.attname, am.amname,
CASE
WHEN idx.indexprs IS NOT NULL THEN
pg_get_indexdef(idx.indexrelid)
...
...
docs/releases/1.11.2.txt
Dosyayı görüntüle @
3a5299c1
...
...
@@ -23,3 +23,5 @@ Bugfixes
* Fixed ``django.contrib.auth.authenticate()`` when multiple authentication
backends don't accept a positional ``request`` argument (:ticket:`28207`).
* Fixed introspection of index field ordering on PostgreSQL (:ticket:`28197`).
tests/introspection/models.py
Dosyayı görüntüle @
3a5299c1
...
...
@@ -47,6 +47,7 @@ class Article(models.Model):
ordering
=
(
'headline'
,)
index_together
=
[
[
"headline"
,
"pub_date"
],
[
'headline'
,
'response_to'
,
'pub_date'
,
'reporter'
],
]
...
...
tests/introspection/tests.py
Dosyayı görüntüle @
3a5299c1
...
...
@@ -189,10 +189,14 @@ class IntrospectionTests(TransactionTestCase):
with
connection
.
cursor
()
as
cursor
:
constraints
=
connection
.
introspection
.
get_constraints
(
cursor
,
Article
.
_meta
.
db_table
)
index
=
{}
index2
=
{}
for
key
,
val
in
constraints
.
items
():
if
val
[
'columns'
]
==
[
'headline'
,
'pub_date'
]:
index
=
val
if
val
[
'columns'
]
==
[
'headline'
,
'response_to_id'
,
'pub_date'
,
'reporter_id'
]:
index2
=
val
self
.
assertEqual
(
index
[
'type'
],
Index
.
suffix
)
self
.
assertEqual
(
index2
[
'type'
],
Index
.
suffix
)
@skipUnlessDBFeature
(
'supports_index_column_ordering'
)
def
test_get_constraints_indexes_orders
(
self
):
...
...
@@ -206,13 +210,14 @@ class IntrospectionTests(TransactionTestCase):
[
'reporter_id'
],
[
'headline'
,
'pub_date'
],
[
'response_to_id'
],
[
'headline'
,
'response_to_id'
,
'pub_date'
,
'reporter_id'
],
]
for
key
,
val
in
constraints
.
items
():
if
val
[
'index'
]
and
not
(
val
[
'primary_key'
]
or
val
[
'unique'
]):
self
.
assertIn
(
val
[
'columns'
],
expected_columns
)
self
.
assertEqual
(
val
[
'orders'
],
[
'ASC'
]
*
len
(
val
[
'columns'
]))
indexes_verified
+=
1
self
.
assertEqual
(
indexes_verified
,
3
)
self
.
assertEqual
(
indexes_verified
,
4
)
def
datatype
(
dbtype
,
description
):
...
...
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