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
f37c11ee
Kaydet (Commit)
f37c11ee
authored
Şub 25, 2015
tarafından
László Károlyi
Kaydeden (comit)
Tim Graham
Mar 02, 2015
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fixed #24390 -- Made migration index names deterministic.
üst
4fdc7015
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
1 deletion
+14
-1
schema.py
django/db/backends/base/schema.py
+1
-1
tests.py
tests/indexes/tests.py
+13
-0
No files found.
django/db/backends/base/schema.py
Dosyayı görüntüle @
f37c11ee
...
...
@@ -798,7 +798,7 @@ class BaseDatabaseSchemaEditor(object):
)
# Else generate the name for the index using a different algorithm
table_name
=
model
.
_meta
.
db_table
.
replace
(
'"'
,
''
)
.
replace
(
'.'
,
'_'
)
index_unique_name
=
'_
%
x'
%
abs
(
hash
((
table_name
,
','
.
join
(
column_names
)))
)
index_unique_name
=
'_
%
s'
%
self
.
_digest
(
*
column_names
)
max_length
=
self
.
connection
.
ops
.
max_name_length
()
or
200
# If the index name is too long, truncate it
index_name
=
(
'
%
s_
%
s
%
s
%
s'
%
(
...
...
tests/indexes/tests.py
Dosyayı görüntüle @
f37c11ee
...
...
@@ -10,6 +10,19 @@ class SchemaIndexesTests(TestCase):
"""
Test index handling by the db.backends.schema infrastructure.
"""
def
test_index_name_hash
(
self
):
"""
Index names should be deterministic.
"""
with
connection
.
schema_editor
()
as
editor
:
index_name
=
editor
.
_create_index_name
(
model
=
Article
,
column_names
=
(
"column1"
,
"column2"
,
"column3"
),
suffix
=
"123"
,
)
self
.
assertEqual
(
index_name
,
"indexes_article_column1_856fe518123"
)
def
test_index_together
(
self
):
editor
=
connection
.
schema_editor
()
index_sql
=
editor
.
_model_indexes_sql
(
Article
)
...
...
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