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
e9e705ee
Kaydet (Commit)
e9e705ee
authored
Tem 08, 2016
tarafından
Jon Dufresne
Kaydeden (comit)
Tim Graham
Tem 08, 2016
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Added strict=True to all SchemaEditor.alter_field() calls in tests.
It should help catch bugs.
üst
8b9e16ec
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
9 deletions
+9
-9
tests.py
tests/schema/tests.py
+9
-9
No files found.
tests/schema/tests.py
Dosyayı görüntüle @
e9e705ee
...
...
@@ -615,7 +615,7 @@ class SchemaTests(TransactionTestCase):
new_field
=
PositiveIntegerField
(
default
=
42
)
new_field
.
set_attributes_from_name
(
"height"
)
with
connection
.
schema_editor
()
as
editor
:
editor
.
alter_field
(
Author
,
old_field
,
new_field
)
editor
.
alter_field
(
Author
,
old_field
,
new_field
,
strict
=
True
)
# Ensure the field is right afterwards
columns
=
self
.
column_classes
(
Author
)
self
.
assertFalse
(
columns
[
'height'
][
1
][
6
])
...
...
@@ -636,7 +636,7 @@ class SchemaTests(TransactionTestCase):
new_field
=
copy
(
old_field
)
new_field
.
null
=
True
with
connection
.
schema_editor
()
as
editor
:
editor
.
alter_field
(
Author
,
old_field
,
new_field
)
editor
.
alter_field
(
Author
,
old_field
,
new_field
,
strict
=
True
)
def
test_alter_textfield_to_null
(
self
):
"""
...
...
@@ -651,7 +651,7 @@ class SchemaTests(TransactionTestCase):
new_field
=
copy
(
old_field
)
new_field
.
null
=
True
with
connection
.
schema_editor
()
as
editor
:
editor
.
alter_field
(
Note
,
old_field
,
new_field
)
editor
.
alter_field
(
Note
,
old_field
,
new_field
,
strict
=
True
)
@skipUnlessDBFeature
(
'supports_combined_alters'
)
def
test_alter_null_to_not_null_keeping_default
(
self
):
...
...
@@ -670,7 +670,7 @@ class SchemaTests(TransactionTestCase):
new_field
=
PositiveIntegerField
(
default
=
42
)
new_field
.
set_attributes_from_name
(
"height"
)
with
connection
.
schema_editor
()
as
editor
:
editor
.
alter_field
(
AuthorWithDefaultHeight
,
old_field
,
new_field
)
editor
.
alter_field
(
AuthorWithDefaultHeight
,
old_field
,
new_field
,
strict
=
True
)
# Ensure the field is right afterwards
columns
=
self
.
column_classes
(
AuthorWithDefaultHeight
)
self
.
assertFalse
(
columns
[
'height'
][
1
][
6
])
...
...
@@ -1189,7 +1189,7 @@ class SchemaTests(TransactionTestCase):
# "Alter" the field. This should not rename the DB table to itself.
with
connection
.
schema_editor
()
as
editor
:
editor
.
alter_field
(
LocalAuthorWithM2M
,
new_field
,
new_field
)
editor
.
alter_field
(
LocalAuthorWithM2M
,
new_field
,
new_field
,
strict
=
True
)
# Remove the M2M table again
with
connection
.
schema_editor
()
as
editor
:
...
...
@@ -1248,7 +1248,7 @@ class SchemaTests(TransactionTestCase):
new_field
=
M2MFieldClass
(
"schema.TagM2MTest"
,
related_name
=
"authors"
,
through
=
LocalAuthorTag
)
new_field
.
contribute_to_class
(
LocalAuthorWithM2MThrough
,
"tags"
)
with
connection
.
schema_editor
()
as
editor
:
editor
.
alter_field
(
LocalAuthorWithM2MThrough
,
old_field
,
new_field
)
editor
.
alter_field
(
LocalAuthorWithM2MThrough
,
old_field
,
new_field
,
strict
=
True
)
# Ensure the m2m table is still there
self
.
assertEqual
(
len
(
self
.
column_classes
(
LocalAuthorTag
)),
3
)
...
...
@@ -1297,7 +1297,7 @@ class SchemaTests(TransactionTestCase):
new_field
=
M2MFieldClass
(
UniqueTest
)
new_field
.
contribute_to_class
(
LocalBookWithM2M
,
"uniques"
)
with
connection
.
schema_editor
()
as
editor
:
editor
.
alter_field
(
LocalBookWithM2M
,
old_field
,
new_field
)
editor
.
alter_field
(
LocalBookWithM2M
,
old_field
,
new_field
,
strict
=
True
)
# Ensure old M2M is gone
with
self
.
assertRaises
(
DatabaseError
):
self
.
column_classes
(
LocalBookWithM2M
.
_meta
.
get_field
(
"tags"
)
.
remote_field
.
through
)
...
...
@@ -1884,7 +1884,7 @@ class SchemaTests(TransactionTestCase):
new_field
=
IntegerField
(
blank
=
True
,
default
=
42
)
new_field
.
set_attributes_from_name
(
'height'
)
with
connection
.
schema_editor
()
as
editor
:
editor
.
alter_field
(
Author
,
old_field
,
new_field
)
editor
.
alter_field
(
Author
,
old_field
,
new_field
,
strict
=
True
)
self
.
assertEqual
(
Author
.
objects
.
get
()
.
height
,
42
)
# The database default should be removed.
with
connection
.
cursor
()
as
cursor
:
...
...
@@ -2117,7 +2117,7 @@ class SchemaTests(TransactionTestCase):
new_field
=
AutoField
(
primary_key
=
True
)
new_field
.
set_attributes_from_name
(
'id'
)
with
connection
.
schema_editor
()
as
editor
:
editor
.
alter_field
(
Node
,
old_field
,
new_field
)
editor
.
alter_field
(
Node
,
old_field
,
new_field
,
strict
=
True
)
@mock.patch
(
'django.db.backends.base.schema.datetime'
)
@mock.patch
(
'django.db.backends.base.schema.timezone'
)
...
...
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