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
f717ef08
Kaydet (Commit)
f717ef08
authored
Haz 15, 2014
tarafından
Andrew Godwin
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fixed #22833: Autodetector not doing through mapping correctly
üst
24afb1d7
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
1 deletion
+20
-1
autodetector.py
django/db/migrations/autodetector.py
+5
-1
test_autodetector.py
tests/migrations/test_autodetector.py
+15
-0
No files found.
django/db/migrations/autodetector.py
Dosyayı görüntüle @
f717ef08
...
...
@@ -127,7 +127,11 @@ class MigrationAutodetector(object):
new_model_state
=
self
.
to_state
.
models
[
app_label
,
model_name
]
self
.
old_field_keys
.
update
((
app_label
,
model_name
,
x
)
for
x
,
y
in
old_model_state
.
fields
)
self
.
new_field_keys
.
update
((
app_label
,
model_name
,
x
)
for
x
,
y
in
new_model_state
.
fields
)
# Through model stuff
# Through model map generation
for
app_label
,
model_name
in
sorted
(
self
.
old_model_keys
):
old_model_name
=
self
.
renamed_models
.
get
((
app_label
,
model_name
),
model_name
)
old_model_state
=
self
.
from_state
.
models
[
app_label
,
old_model_name
]
for
field_name
,
field
in
old_model_state
.
fields
:
old_field
=
self
.
old_apps
.
get_model
(
app_label
,
old_model_name
)
.
_meta
.
get_field_by_name
(
field_name
)[
0
]
if
hasattr
(
old_field
,
"rel"
)
and
hasattr
(
old_field
.
rel
,
"through"
)
and
not
old_field
.
rel
.
through
.
_meta
.
auto_created
:
...
...
tests/migrations/test_autodetector.py
Dosyayı görüntüle @
f717ef08
...
...
@@ -750,6 +750,21 @@ class AutodetectorTests(TestCase):
self
.
assertEqual
(
action
.
__class__
.
__name__
,
"DeleteModel"
)
self
.
assertEqual
(
action
.
name
,
"Attribution"
)
def
test_many_to_many_removed_before_through_model_2
(
self
):
"""
Removing a model that contains a ManyToManyField and the
"through" model in the same change must remove
the field before the model to maintain consistency.
"""
before
=
self
.
make_project_state
([
self
.
book_with_multiple_authors_through_attribution
,
self
.
author_name
,
self
.
attribution
])
after
=
self
.
make_project_state
([
self
.
author_name
])
# removes both the through model and ManyToMany
autodetector
=
MigrationAutodetector
(
before
,
after
)
changes
=
autodetector
.
_detect_changes
()
# Right number of migrations?
self
.
assertNumberMigrations
(
changes
,
'otherapp'
,
1
)
# Right number of actions?
self
.
assertOperationTypes
(
changes
,
'otherapp'
,
0
,
[
"RemoveField"
,
"RemoveField"
,
"RemoveField"
,
"DeleteModel"
,
"DeleteModel"
])
def
test_m2m_w_through_multistep_remove
(
self
):
"""
A model with a m2m field that specifies a "through" model cannot be removed in the same
...
...
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