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
7b4a9945
Kaydet (Commit)
7b4a9945
authored
Kas 17, 2014
tarafından
Markus Holtermann
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fixed #23859 -- Fixed a migration crash when a field is renamed that is part of an index_together
üst
19ae13d9
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
16 additions
and
8 deletions
+16
-8
fields.py
django/db/migrations/operations/fields.py
+7
-6
1.7.2.txt
docs/releases/1.7.2.txt
+3
-0
test_operations.py
tests/migrations/test_operations.py
+6
-2
No files found.
django/db/migrations/operations/fields.py
Dosyayı görüntüle @
7b4a9945
...
@@ -177,13 +177,14 @@ class RenameField(Operation):
...
@@ -177,13 +177,14 @@ class RenameField(Operation):
(
self
.
new_name
if
n
==
self
.
old_name
else
n
,
f
)
(
self
.
new_name
if
n
==
self
.
old_name
else
n
,
f
)
for
n
,
f
in
state
.
models
[
app_label
,
self
.
model_name
.
lower
()]
.
fields
for
n
,
f
in
state
.
models
[
app_label
,
self
.
model_name
.
lower
()]
.
fields
]
]
# Fix unique_together to refer to the new field
# Fix
index/
unique_together to refer to the new field
options
=
state
.
models
[
app_label
,
self
.
model_name
.
lower
()]
.
options
options
=
state
.
models
[
app_label
,
self
.
model_name
.
lower
()]
.
options
if
"unique_together"
in
options
:
for
option
in
(
'index_together'
,
'unique_together'
):
options
[
'unique_together'
]
=
[
if
option
in
options
:
[
self
.
new_name
if
n
==
self
.
old_name
else
n
for
n
in
unique
]
options
[
option
]
=
[
for
unique
in
options
[
'unique_together'
]
[
self
.
new_name
if
n
==
self
.
old_name
else
n
for
n
in
together
]
]
for
together
in
options
[
option
]
]
def
database_forwards
(
self
,
app_label
,
schema_editor
,
from_state
,
to_state
):
def
database_forwards
(
self
,
app_label
,
schema_editor
,
from_state
,
to_state
):
to_model
=
to_state
.
render
()
.
get_model
(
app_label
,
self
.
model_name
)
to_model
=
to_state
.
render
()
.
get_model
(
app_label
,
self
.
model_name
)
...
...
docs/releases/1.7.2.txt
Dosyayı görüntüle @
7b4a9945
...
@@ -59,3 +59,6 @@ Bugfixes
...
@@ -59,3 +59,6 @@ Bugfixes
* Fixed a custom field type validation error with MySQL backend when
* Fixed a custom field type validation error with MySQL backend when
``db_type`` returned ``None`` (:ticket:`23761`).
``db_type`` returned ``None`` (:ticket:`23761`).
* Fixed a migration crash when a field is renamed that is part of an
``index_together`` (:ticket:`23859`).
tests/migrations/test_operations.py
Dosyayı görüntüle @
7b4a9945
...
@@ -49,7 +49,7 @@ class OperationTestBase(MigrationTestBase):
...
@@ -49,7 +49,7 @@ class OperationTestBase(MigrationTestBase):
def
set_up_test_model
(
self
,
app_label
,
second_model
=
False
,
third_model
=
False
,
def
set_up_test_model
(
self
,
app_label
,
second_model
=
False
,
third_model
=
False
,
related_model
=
False
,
mti_model
=
False
,
proxy_model
=
False
,
related_model
=
False
,
mti_model
=
False
,
proxy_model
=
False
,
unique_together
=
False
,
options
=
False
,
db_table
=
None
):
unique_together
=
False
,
options
=
False
,
db_table
=
None
,
index_together
=
False
):
"""
"""
Creates a test model state and database table.
Creates a test model state and database table.
"""
"""
...
@@ -81,6 +81,7 @@ class OperationTestBase(MigrationTestBase):
...
@@ -81,6 +81,7 @@ class OperationTestBase(MigrationTestBase):
# Make the "current" state
# Make the "current" state
model_options
=
{
model_options
=
{
"swappable"
:
"TEST_SWAP_MODEL"
,
"swappable"
:
"TEST_SWAP_MODEL"
,
"index_together"
:
[[
"pink"
,
"weight"
]]
if
index_together
else
[],
"unique_together"
:
[[
"pink"
,
"weight"
]]
if
unique_together
else
[],
"unique_together"
:
[[
"pink"
,
"weight"
]]
if
unique_together
else
[],
}
}
if
options
:
if
options
:
...
@@ -984,7 +985,7 @@ class OperationTests(OperationTestBase):
...
@@ -984,7 +985,7 @@ class OperationTests(OperationTestBase):
"""
"""
Tests the RenameField operation.
Tests the RenameField operation.
"""
"""
project_state
=
self
.
set_up_test_model
(
"test_rnfl"
,
unique_together
=
True
)
project_state
=
self
.
set_up_test_model
(
"test_rnfl"
,
unique_together
=
True
,
index_together
=
True
)
# Test the state alteration
# Test the state alteration
operation
=
migrations
.
RenameField
(
"Pony"
,
"pink"
,
"blue"
)
operation
=
migrations
.
RenameField
(
"Pony"
,
"pink"
,
"blue"
)
self
.
assertEqual
(
operation
.
describe
(),
"Rename field pink on Pony to blue"
)
self
.
assertEqual
(
operation
.
describe
(),
"Rename field pink on Pony to blue"
)
...
@@ -995,6 +996,9 @@ class OperationTests(OperationTestBase):
...
@@ -995,6 +996,9 @@ class OperationTests(OperationTestBase):
# Make sure the unique_together has the renamed column too
# Make sure the unique_together has the renamed column too
self
.
assertIn
(
"blue"
,
new_state
.
models
[
"test_rnfl"
,
"pony"
]
.
options
[
'unique_together'
][
0
])
self
.
assertIn
(
"blue"
,
new_state
.
models
[
"test_rnfl"
,
"pony"
]
.
options
[
'unique_together'
][
0
])
self
.
assertNotIn
(
"pink"
,
new_state
.
models
[
"test_rnfl"
,
"pony"
]
.
options
[
'unique_together'
][
0
])
self
.
assertNotIn
(
"pink"
,
new_state
.
models
[
"test_rnfl"
,
"pony"
]
.
options
[
'unique_together'
][
0
])
# Make sure the index_together has the renamed column too
self
.
assertIn
(
"blue"
,
new_state
.
models
[
"test_rnfl"
,
"pony"
]
.
options
[
'index_together'
][
0
])
self
.
assertNotIn
(
"pink"
,
new_state
.
models
[
"test_rnfl"
,
"pony"
]
.
options
[
'index_together'
][
0
])
# Test the database alteration
# Test the database alteration
self
.
assertColumnExists
(
"test_rnfl_pony"
,
"pink"
)
self
.
assertColumnExists
(
"test_rnfl_pony"
,
"pink"
)
self
.
assertColumnNotExists
(
"test_rnfl_pony"
,
"blue"
)
self
.
assertColumnNotExists
(
"test_rnfl_pony"
,
"blue"
)
...
...
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