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
bdec8480
Kaydet (Commit)
bdec8480
authored
Mar 31, 2014
tarafından
Loic Bistuer
Kaydeden (comit)
Tim Graham
Mar 31, 2014
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
[1.7.x] Fixed #22359 -- Changing M2M field to blank=True failed on sqlite.
Backport of
a449e7fe
from master
üst
422f5d9a
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
9 deletions
+31
-9
schema.py
django/db/backends/sqlite3/schema.py
+1
-1
test_operations.py
tests/migrations/test_operations.py
+30
-8
No files found.
django/db/backends/sqlite3/schema.py
Dosyayı görüntüle @
bdec8480
...
...
@@ -161,7 +161,7 @@ class DatabaseSchemaEditor(BaseDatabaseSchemaEditor):
"""
Alters M2Ms to repoint their to= endpoints.
"""
if
old_field
.
rel
.
through
==
new_field
.
rel
.
through
:
if
old_field
.
rel
.
through
.
_meta
.
db_table
==
new_field
.
rel
.
through
.
_meta
.
db_table
:
return
# Make a new through table
...
...
tests/migrations/test_operations.py
Dosyayı görüntüle @
bdec8480
...
...
@@ -14,6 +14,17 @@ class OperationTests(MigrationTestBase):
both forwards and backwards.
"""
def
apply_operations
(
self
,
app_label
,
project_state
,
operations
):
new_state
=
project_state
.
clone
()
for
operation
in
operations
:
operation
.
state_forwards
(
app_label
,
new_state
)
# Set up the database
with
connection
.
schema_editor
()
as
editor
:
for
operation
in
operations
:
operation
.
database_forwards
(
app_label
,
editor
,
project_state
,
new_state
)
return
new_state
def
set_up_test_model
(
self
,
app_label
,
second_model
=
False
,
related_model
=
False
,
mti_model
=
False
):
"""
Creates a test model state and database table.
...
...
@@ -67,14 +78,8 @@ class OperationTests(MigrationTestBase):
],
bases
=
[
'
%
s.Pony'
%
app_label
],
))
project_state
=
ProjectState
()
for
operation
in
operations
:
operation
.
state_forwards
(
app_label
,
project_state
)
# Set up the database
with
connection
.
schema_editor
()
as
editor
:
for
operation
in
operations
:
operation
.
database_forwards
(
app_label
,
editor
,
ProjectState
(),
project_state
)
return
project_state
return
self
.
apply_operations
(
app_label
,
ProjectState
(),
operations
)
def
test_create_model
(
self
):
"""
...
...
@@ -374,6 +379,23 @@ class OperationTests(MigrationTestBase):
operation
.
database_backwards
(
"test_adflmm"
,
editor
,
new_state
,
project_state
)
self
.
assertTableNotExists
(
"test_adflmm_pony_stables"
)
def
test_alter_field_m2m
(
self
):
project_state
=
self
.
set_up_test_model
(
"test_alflmm"
,
second_model
=
True
)
project_state
=
self
.
apply_operations
(
"test_alflmm"
,
project_state
,
operations
=
[
migrations
.
AddField
(
"Pony"
,
"stables"
,
models
.
ManyToManyField
(
"Stable"
,
related_name
=
"ponies"
))
])
new_apps
=
project_state
.
render
()
Pony
=
new_apps
.
get_model
(
"test_alflmm"
,
"Pony"
)
self
.
assertFalse
(
Pony
.
_meta
.
get_field
(
'stables'
)
.
blank
)
project_state
=
self
.
apply_operations
(
"test_alflmm"
,
project_state
,
operations
=
[
migrations
.
AlterField
(
"Pony"
,
"stables"
,
models
.
ManyToManyField
(
to
=
"Stable"
,
related_name
=
"ponies"
,
blank
=
True
))
])
new_apps
=
project_state
.
render
()
Pony
=
new_apps
.
get_model
(
"test_alflmm"
,
"Pony"
)
self
.
assertTrue
(
Pony
.
_meta
.
get_field
(
'stables'
)
.
blank
)
def
test_remove_field
(
self
):
"""
Tests the RemoveField operation.
...
...
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