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
e244e456
Kaydet (Commit)
e244e456
authored
May 08, 2014
tarafından
Aymeric Augustin
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
[1.7.x] Appeased flake8.
Backport of
b1432bfc
from master
üst
189bcb9b
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
10 additions
and
6 deletions
+10
-6
state.py
django/db/migrations/state.py
+3
-3
tests.py
tests/field_deconstruction/tests.py
+0
-1
test_operations.py
tests/migrations/test_operations.py
+2
-1
tests.py
tests/schema/tests.py
+5
-1
No files found.
django/db/migrations/state.py
Dosyayı görüntüle @
e244e456
...
...
@@ -89,9 +89,9 @@ class ProjectState(object):
# "ValueError: Lookup failed for model referenced by
# field migrations.Book.author: migrations.Author"
raise
ValueError
(
"Lookup failed for model referenced by field {field}: {model[0]}.{model[1]}{extra_message}"
.
format
(
field
=
operations
[
0
][
1
],
model
=
lookup_model
,
extra_message
=
extra_message
,
field
=
operations
[
0
][
1
],
model
=
lookup_model
,
extra_message
=
extra_message
,
))
else
:
do_pending_lookups
(
model
)
...
...
tests/field_deconstruction/tests.py
Dosyayı görüntüle @
e244e456
...
...
@@ -3,7 +3,6 @@ import warnings
from
django.db
import
models
from
django.test
import
TestCase
,
override_settings
from
django.utils
import
six
from
django.core.files.storage
import
FileSystemStorage
class
FieldDeconstructionTests
(
TestCase
):
...
...
tests/migrations/test_operations.py
Dosyayı görüntüle @
e244e456
...
...
@@ -757,10 +757,12 @@ class OperationTests(MigrationTestBase):
Tests the RunPython operation correctly handles the "atomic" keyword
"""
project_state
=
self
.
set_up_test_model
(
"test_runpythonatomic"
,
mti_model
=
True
)
def
inner_method
(
models
,
schema_editor
):
Pony
=
models
.
get_model
(
"test_runpythonatomic"
,
"Pony"
)
Pony
.
objects
.
create
(
pink
=
1
,
weight
=
3.55
)
raise
ValueError
(
"Adrian hates ponies."
)
atomic_migration
=
Migration
(
"test"
,
"test_runpythonatomic"
)
atomic_migration
.
operations
=
[
migrations
.
RunPython
(
inner_method
)]
non_atomic_migration
=
Migration
(
"test"
,
"test_runpythonatomic"
)
...
...
@@ -789,7 +791,6 @@ class OperationTests(MigrationTestBase):
self
.
assertEqual
(
project_state
.
render
()
.
get_model
(
"test_runpythonatomic"
,
"Pony"
)
.
objects
.
count
(),
1
)
class
MigrateNothingRouter
(
object
):
"""
A router that sends all writes to the other database.
...
...
tests/schema/tests.py
Dosyayı görüntüle @
e244e456
...
...
@@ -236,14 +236,18 @@ class SchemaTests(TransactionTestCase):
Tests adding fields to models with a default that is not directly
valid in the database (#22581)
"""
class
TestTransformField
(
IntegerField
):
# Weird field that saves the count of items in its value
def
get_default
(
self
):
return
self
.
default
def
get_prep_value
(
self
,
value
):
if
value
is
None
:
return
0
return
len
(
value
)
# Create the table
with
connection
.
schema_editor
()
as
editor
:
editor
.
create_model
(
Author
)
...
...
@@ -251,7 +255,7 @@ class SchemaTests(TransactionTestCase):
Author
.
objects
.
create
(
name
=
"Andrew"
,
height
=
30
)
Author
.
objects
.
create
(
name
=
"Andrea"
)
# Add the field with a default it needs to cast (to string in this case)
new_field
=
TestTransformField
(
default
=
{
1
:
2
})
new_field
=
TestTransformField
(
default
=
{
1
:
2
})
new_field
.
set_attributes_from_name
(
"thing"
)
with
connection
.
schema_editor
()
as
editor
:
editor
.
add_field
(
...
...
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