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
72729f84
Kaydet (Commit)
72729f84
authored
Kas 15, 2014
tarafından
Andrzej Pragacz
Kaydeden (comit)
Tim Graham
Kas 21, 2014
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fixed #23794 -- Fixed migrations crash when removing a field that's part of index/unique_together.
üst
f957e2b0
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
24 additions
and
11 deletions
+24
-11
autodetector.py
django/db/migrations/autodetector.py
+5
-11
1.7.2.txt
docs/releases/1.7.2.txt
+3
-0
test_autodetector.py
tests/migrations/test_autodetector.py
+16
-0
No files found.
django/db/migrations/autodetector.py
Dosyayı görüntüle @
72729f84
...
@@ -366,17 +366,11 @@ class MigrationAutodetector(object):
...
@@ -366,17 +366,11 @@ class MigrationAutodetector(object):
)
)
# Field is removed and part of an index/unique_together
# Field is removed and part of an index/unique_together
elif
dependency
[
2
]
is
not
None
and
dependency
[
3
]
==
"foo_together_change"
:
elif
dependency
[
2
]
is
not
None
and
dependency
[
3
]
==
"foo_together_change"
:
if
operation
.
name
.
lower
()
==
dependency
[
1
]
.
lower
():
return
(
return
(
isinstance
(
operation
,
(
operations
.
AlterUniqueTogether
,
(
operations
.
AlterIndexTogether
))
and
isinstance
(
operation
,
operations
.
AlterUniqueTogether
)
and
operation
.
name
.
lower
()
==
dependency
[
1
]
.
lower
()
any
(
dependency
[
2
]
not
in
t
for
t
in
operation
.
unique_together
)
)
)
or
(
isinstance
(
operation
,
operations
.
AlterIndexTogether
)
and
any
(
dependency
[
2
]
not
in
t
for
t
in
operation
.
index_together
)
)
)
# Unknown dependency. Raise an error.
# Unknown dependency. Raise an error.
else
:
else
:
raise
ValueError
(
"Can't handle dependency
%
r"
%
(
dependency
,
))
raise
ValueError
(
"Can't handle dependency
%
r"
%
(
dependency
,
))
...
...
docs/releases/1.7.2.txt
Dosyayı görüntüle @
72729f84
...
@@ -74,3 +74,6 @@ Bugfixes
...
@@ -74,3 +74,6 @@ Bugfixes
* Fixed a rare query error when using deeply nested subqueries
* Fixed a rare query error when using deeply nested subqueries
(:ticket:`23605`).
(:ticket:`23605`).
* Fixed a crash in migrations when deleting a field that is part of a
``index/unique_together`` constraint (:ticket:`23794`).
tests/migrations/test_autodetector.py
Dosyayı görüntüle @
72729f84
...
@@ -908,6 +908,22 @@ class AutodetectorTests(TestCase):
...
@@ -908,6 +908,22 @@ class AutodetectorTests(TestCase):
self
.
assertOperationAttributes
(
changes
,
"otherapp"
,
0
,
0
,
name
=
"book"
,
unique_together
=
set
())
self
.
assertOperationAttributes
(
changes
,
"otherapp"
,
0
,
0
,
name
=
"book"
,
unique_together
=
set
())
self
.
assertOperationAttributes
(
changes
,
"otherapp"
,
0
,
1
,
name
=
"book"
,
index_together
=
set
())
self
.
assertOperationAttributes
(
changes
,
"otherapp"
,
0
,
1
,
name
=
"book"
,
index_together
=
set
())
def
test_foo_together_remove_fk
(
self
):
"""Tests unique_together and field removal detection & ordering"""
# Make state
before
=
self
.
make_project_state
([
self
.
author_empty
,
self
.
book_foo_together
])
after
=
self
.
make_project_state
([
self
.
author_empty
,
self
.
book_with_no_author
])
autodetector
=
MigrationAutodetector
(
before
,
after
)
changes
=
autodetector
.
_detect_changes
()
# Right number/type of migrations?
self
.
assertNumberMigrations
(
changes
,
"otherapp"
,
1
)
self
.
assertOperationTypes
(
changes
,
"otherapp"
,
0
,
[
"AlterUniqueTogether"
,
"AlterIndexTogether"
,
"RemoveField"
])
self
.
assertOperationAttributes
(
changes
,
"otherapp"
,
0
,
0
,
name
=
"book"
,
unique_together
=
set
())
self
.
assertOperationAttributes
(
changes
,
"otherapp"
,
0
,
1
,
name
=
"book"
,
index_together
=
set
())
self
.
assertOperationAttributes
(
changes
,
"otherapp"
,
0
,
2
,
model_name
=
"book"
,
name
=
"author"
)
def
test_foo_together_no_changes
(
self
):
def
test_foo_together_no_changes
(
self
):
"""
"""
Tests that index/unique_together doesn't generate a migration if no
Tests that index/unique_together doesn't generate a migration if no
...
...
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