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
7156a6c9
Kaydet (Commit)
7156a6c9
authored
Ock 10, 2017
tarafından
Ed Morley
Kaydeden (comit)
Tim Graham
Ock 10, 2017
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fixed #27717 -- Allowed migration optimization across AlterModelOptions.
üst
6872ce22
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
0 deletions
+23
-0
models.py
django/db/migrations/operations/models.py
+12
-0
test_optimizer.py
tests/migrations/test_optimizer.py
+11
-0
No files found.
django/db/migrations/operations/models.py
Dosyayı görüntüle @
7156a6c9
...
...
@@ -151,6 +151,18 @@ class CreateModel(ModelOperation):
managers
=
self
.
managers
,
),
]
elif
isinstance
(
operation
,
AlterModelOptions
)
and
self
.
name_lower
==
operation
.
name_lower
:
new_options
=
self
.
options
.
copy
()
new_options
.
update
(
operation
.
options
)
return
[
CreateModel
(
self
.
name
,
fields
=
self
.
fields
,
options
=
new_options
,
bases
=
self
.
bases
,
managers
=
self
.
managers
,
),
]
elif
isinstance
(
operation
,
FieldOperation
)
and
self
.
name_lower
==
operation
.
model_name_lower
:
if
isinstance
(
operation
,
AddField
):
# Don't allow optimizations of FKs through models they reference
...
...
tests/migrations/test_optimizer.py
Dosyayı görüntüle @
7156a6c9
...
...
@@ -101,6 +101,17 @@ class OptimizerTests(SimpleTestCase):
],
)
def
test_create_alter_model_options
(
self
):
self
.
assertOptimizesTo
(
[
migrations
.
CreateModel
(
'Foo'
,
fields
=
[]),
migrations
.
AlterModelOptions
(
name
=
'Foo'
,
options
=
{
'verbose_name_plural'
:
'Foozes'
}),
],
[
migrations
.
CreateModel
(
'Foo'
,
fields
=
[],
options
=
{
'verbose_name_plural'
:
'Foozes'
}),
]
)
def
_test_create_alter_foo_delete_model
(
self
,
alter_foo
):
"""
CreateModel, AlterModelTable, AlterUniqueTogether/AlterIndexTogether/
...
...
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