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
b008f7cc
Kaydet (Commit)
b008f7cc
authored
Şub 15, 2017
tarafından
Tim Graham
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fixed #27135 -- Made index introspection return Index.suffix.
üst
a7214f0e
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
22 additions
and
9 deletions
+22
-9
introspection.py
django/db/backends/mysql/introspection.py
+2
-1
introspection.py
django/db/backends/oracle/introspection.py
+1
-1
introspection.py
django/db/backends/postgresql/introspection.py
+2
-1
introspection.py
django/db/backends/sqlite3/introspection.py
+2
-1
tests.py
tests/introspection/tests.py
+2
-1
tests.py
tests/model_indexes/tests.py
+5
-2
test_indexes.py
tests/postgres_tests/test_indexes.py
+8
-2
No files found.
django/db/backends/mysql/introspection.py
Dosyayı görüntüle @
b008f7cc
...
...
@@ -6,6 +6,7 @@ from MySQLdb.constants import FIELD_TYPE
from
django.db.backends.base.introspection
import
(
BaseDatabaseIntrospection
,
FieldInfo
,
TableInfo
,
)
from
django.db.models.indexes
import
Index
from
django.utils.datastructures
import
OrderedSet
from
django.utils.deprecation
import
RemovedInDjango21Warning
from
django.utils.encoding
import
force_text
...
...
@@ -217,7 +218,7 @@ class DatabaseIntrospection(BaseDatabaseIntrospection):
'foreign_key'
:
None
,
}
constraints
[
index
][
'index'
]
=
True
constraints
[
index
][
'type'
]
=
type_
.
lower
()
constraints
[
index
][
'type'
]
=
Index
.
suffix
if
type_
==
'BTREE'
else
type_
.
lower
()
constraints
[
index
][
'columns'
]
.
add
(
column
)
# Convert the sorted sets to lists
for
constraint
in
constraints
.
values
():
...
...
django/db/backends/oracle/introspection.py
Dosyayı görüntüle @
b008f7cc
...
...
@@ -274,7 +274,7 @@ class DatabaseIntrospection(BaseDatabaseIntrospection):
"foreign_key"
:
None
,
"check"
:
False
,
"index"
:
True
,
"type"
:
'
btree
'
if
type_
==
'normal'
else
type_
,
"type"
:
'
idx
'
if
type_
==
'normal'
else
type_
,
}
# Record the details
constraints
[
constraint
][
'columns'
]
.
append
(
column
)
...
...
django/db/backends/postgresql/introspection.py
Dosyayı görüntüle @
b008f7cc
...
...
@@ -3,6 +3,7 @@ import warnings
from
django.db.backends.base.introspection
import
(
BaseDatabaseIntrospection
,
FieldInfo
,
TableInfo
,
)
from
django.db.models.indexes
import
Index
from
django.utils.deprecation
import
RemovedInDjango21Warning
from
django.utils.encoding
import
force_text
...
...
@@ -234,7 +235,7 @@ class DatabaseIntrospection(BaseDatabaseIntrospection):
"foreign_key"
:
None
,
"check"
:
False
,
"index"
:
True
,
"type"
:
type_
,
"type"
:
Index
.
suffix
if
type_
==
'btree'
else
type_
,
"definition"
:
definition
,
"options"
:
options
,
}
...
...
django/db/backends/sqlite3/introspection.py
Dosyayı görüntüle @
b008f7cc
...
...
@@ -4,6 +4,7 @@ import warnings
from
django.db.backends.base.introspection
import
(
BaseDatabaseIntrospection
,
FieldInfo
,
TableInfo
,
)
from
django.db.models.indexes
import
Index
from
django.utils.deprecation
import
RemovedInDjango21Warning
field_size_re
=
re
.
compile
(
r'^\s*(?:var)?char\s*\(\s*(\d+)\s*\)\s*$'
)
...
...
@@ -262,7 +263,7 @@ class DatabaseIntrospection(BaseDatabaseIntrospection):
# Add type and column orders for indexes
if
constraints
[
index
][
'index'
]
and
not
constraints
[
index
][
'unique'
]:
# SQLite doesn't support any index type other than b-tree
constraints
[
index
][
'type'
]
=
'btree'
constraints
[
index
][
'type'
]
=
Index
.
suffix
cursor
.
execute
(
"SELECT sql FROM sqlite_master "
"WHERE type='index' AND name=
%
s"
%
self
.
connection
.
ops
.
quote_name
(
index
)
...
...
tests/introspection/tests.py
Dosyayı görüntüle @
b008f7cc
from
unittest
import
mock
,
skipUnless
from
django.db
import
connection
from
django.db.models
import
Index
from
django.db.utils
import
DatabaseError
from
django.test
import
TransactionTestCase
,
skipUnlessDBFeature
from
django.test.utils
import
ignore_warnings
...
...
@@ -191,7 +192,7 @@ class IntrospectionTests(TransactionTestCase):
for
key
,
val
in
constraints
.
items
():
if
val
[
'columns'
]
==
[
'headline'
,
'pub_date'
]:
index
=
val
self
.
assertEqual
(
index
[
'type'
],
'btree'
)
self
.
assertEqual
(
index
[
'type'
],
Index
.
suffix
)
@skipUnlessDBFeature
(
'supports_index_column_ordering'
)
def
test_get_constraints_indexes_orders
(
self
):
...
...
tests/model_indexes/tests.py
Dosyayı görüntüle @
b008f7cc
from
django.db
import
models
from
django.test
import
TestCase
from
django.test
import
Simple
TestCase
from
.models
import
Book
class
IndexesTests
(
TestCase
):
class
IndexesTests
(
SimpleTestCase
):
def
test_suffix
(
self
):
self
.
assertEqual
(
models
.
Index
.
suffix
,
'idx'
)
def
test_repr
(
self
):
index
=
models
.
Index
(
fields
=
[
'title'
])
...
...
tests/postgres_tests/test_indexes.py
Dosyayı görüntüle @
b008f7cc
...
...
@@ -9,6 +9,9 @@ from .models import CharFieldModel, IntegerArrayModel
@skipUnlessDBFeature
(
'has_brin_index_support'
)
class
BrinIndexTests
(
PostgreSQLTestCase
):
def
test_suffix
(
self
):
self
.
assertEqual
(
BrinIndex
.
suffix
,
'brin'
)
def
test_repr
(
self
):
index
=
BrinIndex
(
fields
=
[
'title'
],
pages_per_range
=
4
)
another_index
=
BrinIndex
(
fields
=
[
'title'
])
...
...
@@ -41,6 +44,9 @@ class BrinIndexTests(PostgreSQLTestCase):
class
GinIndexTests
(
PostgreSQLTestCase
):
def
test_suffix
(
self
):
self
.
assertEqual
(
GinIndex
.
suffix
,
'gin'
)
def
test_repr
(
self
):
index
=
GinIndex
(
fields
=
[
'title'
])
self
.
assertEqual
(
repr
(
index
),
"<GinIndex: fields='title'>"
)
...
...
@@ -84,7 +90,7 @@ class SchemaTests(PostgreSQLTestCase):
editor
.
add_index
(
IntegerArrayModel
,
index
)
constraints
=
self
.
get_constraints
(
IntegerArrayModel
.
_meta
.
db_table
)
# Check gin index was added
self
.
assertEqual
(
constraints
[
index_name
][
'type'
],
'gin'
)
self
.
assertEqual
(
constraints
[
index_name
][
'type'
],
GinIndex
.
suffix
)
# Drop the index
with
connection
.
schema_editor
()
as
editor
:
editor
.
remove_index
(
IntegerArrayModel
,
index
)
...
...
@@ -97,7 +103,7 @@ class SchemaTests(PostgreSQLTestCase):
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'
],
'brin'
)
self
.
assertEqual
(
constraints
[
index_name
][
'type'
],
BrinIndex
.
suffix
)
self
.
assertEqual
(
constraints
[
index_name
][
'options'
],
[
'pages_per_range=4'
])
with
connection
.
schema_editor
()
as
editor
:
editor
.
remove_index
(
CharFieldModel
,
index
)
...
...
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