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
54fdf590
Kaydet (Commit)
54fdf590
authored
Haz 27, 2014
tarafından
Tim Graham
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
[1.7.x] Fixed #22917 -- Fixed typo in AlterIndexTogether.describe().
Backport of
70576740
from master
üst
8e48ca47
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
2 deletions
+18
-2
models.py
django/db/migrations/operations/models.py
+2
-2
test_operations.py
tests/migrations/test_operations.py
+16
-0
No files found.
django/db/migrations/operations/models.py
Dosyayı görüntüle @
54fdf590
...
@@ -248,7 +248,7 @@ class AlterUniqueTogether(Operation):
...
@@ -248,7 +248,7 @@ class AlterUniqueTogether(Operation):
return
name
.
lower
()
==
self
.
name
.
lower
()
return
name
.
lower
()
==
self
.
name
.
lower
()
def
describe
(
self
):
def
describe
(
self
):
return
"Alter
%
s for
%
s (
%
s constraint
s
)"
%
(
self
.
option_name
,
self
.
name
,
len
(
self
.
unique_together
))
return
"Alter
%
s for
%
s (
%
s constraint
(s)
)"
%
(
self
.
option_name
,
self
.
name
,
len
(
self
.
unique_together
))
class
AlterIndexTogether
(
Operation
):
class
AlterIndexTogether
(
Operation
):
...
@@ -288,7 +288,7 @@ class AlterIndexTogether(Operation):
...
@@ -288,7 +288,7 @@ class AlterIndexTogether(Operation):
return
name
.
lower
()
==
self
.
name
.
lower
()
return
name
.
lower
()
==
self
.
name
.
lower
()
def
describe
(
self
):
def
describe
(
self
):
return
"Alter
%
s for
%
s (
%
s constraint
s)"
%
(
self
.
self
.
option_name
,
self
.
name
,
len
(
self
.
index_together
))
return
"Alter
%
s for
%
s (
%
s constraint
(s))"
%
(
self
.
option_name
,
self
.
name
,
len
(
self
.
index_together
))
class
AlterOrderWithRespectTo
(
Operation
):
class
AlterOrderWithRespectTo
(
Operation
):
...
...
tests/migrations/test_operations.py
Dosyayı görüntüle @
54fdf590
...
@@ -154,6 +154,7 @@ class OperationTests(OperationTestBase):
...
@@ -154,6 +154,7 @@ class OperationTests(OperationTestBase):
(
"pink"
,
models
.
IntegerField
(
default
=
1
)),
(
"pink"
,
models
.
IntegerField
(
default
=
1
)),
],
],
)
)
self
.
assertEqual
(
operation
.
describe
(),
"Create model Pony"
)
# Test the state alteration
# Test the state alteration
project_state
=
ProjectState
()
project_state
=
ProjectState
()
new_state
=
project_state
.
clone
()
new_state
=
project_state
.
clone
()
...
@@ -303,6 +304,7 @@ class OperationTests(OperationTestBase):
...
@@ -303,6 +304,7 @@ class OperationTests(OperationTestBase):
options
=
{
"proxy"
:
True
},
options
=
{
"proxy"
:
True
},
bases
=
(
"test_crprmo.Pony"
,
),
bases
=
(
"test_crprmo.Pony"
,
),
)
)
self
.
assertEqual
(
operation
.
describe
(),
"Create proxy model ProxyPony"
)
new_state
=
project_state
.
clone
()
new_state
=
project_state
.
clone
()
operation
.
state_forwards
(
"test_crprmo"
,
new_state
)
operation
.
state_forwards
(
"test_crprmo"
,
new_state
)
self
.
assertIn
((
"test_crprmo"
,
"proxypony"
),
new_state
.
models
)
self
.
assertIn
((
"test_crprmo"
,
"proxypony"
),
new_state
.
models
)
...
@@ -326,6 +328,7 @@ class OperationTests(OperationTestBase):
...
@@ -326,6 +328,7 @@ class OperationTests(OperationTestBase):
project_state
=
self
.
set_up_test_model
(
"test_dlmo"
)
project_state
=
self
.
set_up_test_model
(
"test_dlmo"
)
# Test the state alteration
# Test the state alteration
operation
=
migrations
.
DeleteModel
(
"Pony"
)
operation
=
migrations
.
DeleteModel
(
"Pony"
)
self
.
assertEqual
(
operation
.
describe
(),
"Delete model Pony"
)
new_state
=
project_state
.
clone
()
new_state
=
project_state
.
clone
()
operation
.
state_forwards
(
"test_dlmo"
,
new_state
)
operation
.
state_forwards
(
"test_dlmo"
,
new_state
)
self
.
assertNotIn
((
"test_dlmo"
,
"pony"
),
new_state
.
models
)
self
.
assertNotIn
((
"test_dlmo"
,
"pony"
),
new_state
.
models
)
...
@@ -370,6 +373,7 @@ class OperationTests(OperationTestBase):
...
@@ -370,6 +373,7 @@ class OperationTests(OperationTestBase):
project_state
=
self
.
set_up_test_model
(
"test_rnmo"
,
related_model
=
True
)
project_state
=
self
.
set_up_test_model
(
"test_rnmo"
,
related_model
=
True
)
# Test the state alteration
# Test the state alteration
operation
=
migrations
.
RenameModel
(
"Pony"
,
"Horse"
)
operation
=
migrations
.
RenameModel
(
"Pony"
,
"Horse"
)
self
.
assertEqual
(
operation
.
describe
(),
"Rename model Pony to Horse"
)
new_state
=
project_state
.
clone
()
new_state
=
project_state
.
clone
()
operation
.
state_forwards
(
"test_rnmo"
,
new_state
)
operation
.
state_forwards
(
"test_rnmo"
,
new_state
)
self
.
assertNotIn
((
"test_rnmo"
,
"pony"
),
new_state
.
models
)
self
.
assertNotIn
((
"test_rnmo"
,
"pony"
),
new_state
.
models
)
...
@@ -408,6 +412,7 @@ class OperationTests(OperationTestBase):
...
@@ -408,6 +412,7 @@ class OperationTests(OperationTestBase):
"height"
,
"height"
,
models
.
FloatField
(
null
=
True
,
default
=
5
),
models
.
FloatField
(
null
=
True
,
default
=
5
),
)
)
self
.
assertEqual
(
operation
.
describe
(),
"Add field height to Pony"
)
project_state
,
new_state
=
self
.
make_test_state
(
"test_adfl"
,
operation
)
project_state
,
new_state
=
self
.
make_test_state
(
"test_adfl"
,
operation
)
self
.
assertEqual
(
len
(
new_state
.
models
[
"test_adfl"
,
"pony"
]
.
fields
),
4
)
self
.
assertEqual
(
len
(
new_state
.
models
[
"test_adfl"
,
"pony"
]
.
fields
),
4
)
field
=
[
field
=
[
...
@@ -709,6 +714,7 @@ class OperationTests(OperationTestBase):
...
@@ -709,6 +714,7 @@ class OperationTests(OperationTestBase):
project_state
=
self
.
set_up_test_model
(
"test_rmfl"
)
project_state
=
self
.
set_up_test_model
(
"test_rmfl"
)
# Test the state alteration
# Test the state alteration
operation
=
migrations
.
RemoveField
(
"Pony"
,
"pink"
)
operation
=
migrations
.
RemoveField
(
"Pony"
,
"pink"
)
self
.
assertEqual
(
operation
.
describe
(),
"Remove field pink from Pony"
)
new_state
=
project_state
.
clone
()
new_state
=
project_state
.
clone
()
operation
.
state_forwards
(
"test_rmfl"
,
new_state
)
operation
.
state_forwards
(
"test_rmfl"
,
new_state
)
self
.
assertEqual
(
len
(
new_state
.
models
[
"test_rmfl"
,
"pony"
]
.
fields
),
2
)
self
.
assertEqual
(
len
(
new_state
.
models
[
"test_rmfl"
,
"pony"
]
.
fields
),
2
)
...
@@ -729,6 +735,7 @@ class OperationTests(OperationTestBase):
...
@@ -729,6 +735,7 @@ class OperationTests(OperationTestBase):
project_state
=
self
.
set_up_test_model
(
"test_rfk"
,
related_model
=
True
)
project_state
=
self
.
set_up_test_model
(
"test_rfk"
,
related_model
=
True
)
self
.
assertColumnExists
(
"test_rfk_rider"
,
"pony_id"
)
self
.
assertColumnExists
(
"test_rfk_rider"
,
"pony_id"
)
operation
=
migrations
.
RemoveField
(
"Rider"
,
"pony"
)
operation
=
migrations
.
RemoveField
(
"Rider"
,
"pony"
)
new_state
=
project_state
.
clone
()
new_state
=
project_state
.
clone
()
operation
.
state_forwards
(
"test_rfk"
,
new_state
)
operation
.
state_forwards
(
"test_rfk"
,
new_state
)
with
connection
.
schema_editor
()
as
editor
:
with
connection
.
schema_editor
()
as
editor
:
...
@@ -745,6 +752,7 @@ class OperationTests(OperationTestBase):
...
@@ -745,6 +752,7 @@ class OperationTests(OperationTestBase):
project_state
=
self
.
set_up_test_model
(
"test_almota"
)
project_state
=
self
.
set_up_test_model
(
"test_almota"
)
# Test the state alteration
# Test the state alteration
operation
=
migrations
.
AlterModelTable
(
"Pony"
,
"test_almota_pony_2"
)
operation
=
migrations
.
AlterModelTable
(
"Pony"
,
"test_almota_pony_2"
)
self
.
assertEqual
(
operation
.
describe
(),
"Rename table for Pony to test_almota_pony_2"
)
new_state
=
project_state
.
clone
()
new_state
=
project_state
.
clone
()
operation
.
state_forwards
(
"test_almota"
,
new_state
)
operation
.
state_forwards
(
"test_almota"
,
new_state
)
self
.
assertEqual
(
new_state
.
models
[
"test_almota"
,
"pony"
]
.
options
[
"db_table"
],
"test_almota_pony_2"
)
self
.
assertEqual
(
new_state
.
models
[
"test_almota"
,
"pony"
]
.
options
[
"db_table"
],
"test_almota_pony_2"
)
...
@@ -768,6 +776,7 @@ class OperationTests(OperationTestBase):
...
@@ -768,6 +776,7 @@ class OperationTests(OperationTestBase):
project_state
=
self
.
set_up_test_model
(
"test_alfl"
)
project_state
=
self
.
set_up_test_model
(
"test_alfl"
)
# Test the state alteration
# Test the state alteration
operation
=
migrations
.
AlterField
(
"Pony"
,
"pink"
,
models
.
IntegerField
(
null
=
True
))
operation
=
migrations
.
AlterField
(
"Pony"
,
"pink"
,
models
.
IntegerField
(
null
=
True
))
self
.
assertEqual
(
operation
.
describe
(),
"Alter field pink on Pony"
)
new_state
=
project_state
.
clone
()
new_state
=
project_state
.
clone
()
operation
.
state_forwards
(
"test_alfl"
,
new_state
)
operation
.
state_forwards
(
"test_alfl"
,
new_state
)
self
.
assertEqual
(
project_state
.
models
[
"test_alfl"
,
"pony"
]
.
get_field_by_name
(
"pink"
)
.
null
,
False
)
self
.
assertEqual
(
project_state
.
models
[
"test_alfl"
,
"pony"
]
.
get_field_by_name
(
"pink"
)
.
null
,
False
)
...
@@ -836,6 +845,7 @@ class OperationTests(OperationTestBase):
...
@@ -836,6 +845,7 @@ class OperationTests(OperationTestBase):
project_state
=
self
.
set_up_test_model
(
"test_rnfl"
)
project_state
=
self
.
set_up_test_model
(
"test_rnfl"
)
# Test the state alteration
# Test the state alteration
operation
=
migrations
.
RenameField
(
"Pony"
,
"pink"
,
"blue"
)
operation
=
migrations
.
RenameField
(
"Pony"
,
"pink"
,
"blue"
)
self
.
assertEqual
(
operation
.
describe
(),
"Rename field pink on Pony to blue"
)
new_state
=
project_state
.
clone
()
new_state
=
project_state
.
clone
()
operation
.
state_forwards
(
"test_rnfl"
,
new_state
)
operation
.
state_forwards
(
"test_rnfl"
,
new_state
)
self
.
assertIn
(
"blue"
,
[
n
for
n
,
f
in
new_state
.
models
[
"test_rnfl"
,
"pony"
]
.
fields
])
self
.
assertIn
(
"blue"
,
[
n
for
n
,
f
in
new_state
.
models
[
"test_rnfl"
,
"pony"
]
.
fields
])
...
@@ -860,6 +870,7 @@ class OperationTests(OperationTestBase):
...
@@ -860,6 +870,7 @@ class OperationTests(OperationTestBase):
project_state
=
self
.
set_up_test_model
(
"test_alunto"
)
project_state
=
self
.
set_up_test_model
(
"test_alunto"
)
# Test the state alteration
# Test the state alteration
operation
=
migrations
.
AlterUniqueTogether
(
"Pony"
,
[(
"pink"
,
"weight"
)])
operation
=
migrations
.
AlterUniqueTogether
(
"Pony"
,
[(
"pink"
,
"weight"
)])
self
.
assertEqual
(
operation
.
describe
(),
"Alter unique_together for Pony (1 constraint(s))"
)
new_state
=
project_state
.
clone
()
new_state
=
project_state
.
clone
()
operation
.
state_forwards
(
"test_alunto"
,
new_state
)
operation
.
state_forwards
(
"test_alunto"
,
new_state
)
self
.
assertEqual
(
len
(
project_state
.
models
[
"test_alunto"
,
"pony"
]
.
options
.
get
(
"unique_together"
,
set
())),
0
)
self
.
assertEqual
(
len
(
project_state
.
models
[
"test_alunto"
,
"pony"
]
.
options
.
get
(
"unique_together"
,
set
())),
0
)
...
@@ -895,6 +906,7 @@ class OperationTests(OperationTestBase):
...
@@ -895,6 +906,7 @@ class OperationTests(OperationTestBase):
project_state
=
self
.
set_up_test_model
(
"test_alinto"
)
project_state
=
self
.
set_up_test_model
(
"test_alinto"
)
# Test the state alteration
# Test the state alteration
operation
=
migrations
.
AlterIndexTogether
(
"Pony"
,
[(
"pink"
,
"weight"
)])
operation
=
migrations
.
AlterIndexTogether
(
"Pony"
,
[(
"pink"
,
"weight"
)])
self
.
assertEqual
(
operation
.
describe
(),
"Alter index_together for Pony (1 constraint(s))"
)
new_state
=
project_state
.
clone
()
new_state
=
project_state
.
clone
()
operation
.
state_forwards
(
"test_alinto"
,
new_state
)
operation
.
state_forwards
(
"test_alinto"
,
new_state
)
self
.
assertEqual
(
len
(
project_state
.
models
[
"test_alinto"
,
"pony"
]
.
options
.
get
(
"index_together"
,
set
())),
0
)
self
.
assertEqual
(
len
(
project_state
.
models
[
"test_alinto"
,
"pony"
]
.
options
.
get
(
"index_together"
,
set
())),
0
)
...
@@ -917,6 +929,7 @@ class OperationTests(OperationTestBase):
...
@@ -917,6 +929,7 @@ class OperationTests(OperationTestBase):
project_state
=
self
.
set_up_test_model
(
"test_almoop"
)
project_state
=
self
.
set_up_test_model
(
"test_almoop"
)
# Test the state alteration (no DB alteration to test)
# Test the state alteration (no DB alteration to test)
operation
=
migrations
.
AlterModelOptions
(
"Pony"
,
{
"permissions"
:
[(
"can_groom"
,
"Can groom"
)]})
operation
=
migrations
.
AlterModelOptions
(
"Pony"
,
{
"permissions"
:
[(
"can_groom"
,
"Can groom"
)]})
self
.
assertEqual
(
operation
.
describe
(),
"Change Meta options on Pony"
)
new_state
=
project_state
.
clone
()
new_state
=
project_state
.
clone
()
operation
.
state_forwards
(
"test_almoop"
,
new_state
)
operation
.
state_forwards
(
"test_almoop"
,
new_state
)
self
.
assertEqual
(
len
(
project_state
.
models
[
"test_almoop"
,
"pony"
]
.
options
.
get
(
"permissions"
,
[])),
0
)
self
.
assertEqual
(
len
(
project_state
.
models
[
"test_almoop"
,
"pony"
]
.
options
.
get
(
"permissions"
,
[])),
0
)
...
@@ -930,6 +943,7 @@ class OperationTests(OperationTestBase):
...
@@ -930,6 +943,7 @@ class OperationTests(OperationTestBase):
project_state
=
self
.
set_up_test_model
(
"test_alorwrtto"
,
related_model
=
True
)
project_state
=
self
.
set_up_test_model
(
"test_alorwrtto"
,
related_model
=
True
)
# Test the state alteration
# Test the state alteration
operation
=
migrations
.
AlterOrderWithRespectTo
(
"Rider"
,
"pony"
)
operation
=
migrations
.
AlterOrderWithRespectTo
(
"Rider"
,
"pony"
)
self
.
assertEqual
(
operation
.
describe
(),
"Set order_with_respect_to on Rider to pony"
)
new_state
=
project_state
.
clone
()
new_state
=
project_state
.
clone
()
operation
.
state_forwards
(
"test_alorwrtto"
,
new_state
)
operation
.
state_forwards
(
"test_alorwrtto"
,
new_state
)
self
.
assertEqual
(
project_state
.
models
[
"test_alorwrtto"
,
"rider"
]
.
options
.
get
(
"order_with_respect_to"
,
None
),
None
)
self
.
assertEqual
(
project_state
.
models
[
"test_alorwrtto"
,
"rider"
]
.
options
.
get
(
"order_with_respect_to"
,
None
),
None
)
...
@@ -960,6 +974,7 @@ class OperationTests(OperationTestBase):
...
@@ -960,6 +974,7 @@ class OperationTests(OperationTestBase):
"DROP TABLE i_love_ponies"
,
"DROP TABLE i_love_ponies"
,
state_operations
=
[
migrations
.
CreateModel
(
"SomethingElse"
,
[(
"id"
,
models
.
AutoField
(
primary_key
=
True
))])],
state_operations
=
[
migrations
.
CreateModel
(
"SomethingElse"
,
[(
"id"
,
models
.
AutoField
(
primary_key
=
True
))])],
)
)
self
.
assertEqual
(
operation
.
describe
(),
"Raw SQL operation"
)
# Test the state alteration
# Test the state alteration
new_state
=
project_state
.
clone
()
new_state
=
project_state
.
clone
()
operation
.
state_forwards
(
"test_runsql"
,
new_state
)
operation
.
state_forwards
(
"test_runsql"
,
new_state
)
...
@@ -998,6 +1013,7 @@ class OperationTests(OperationTestBase):
...
@@ -998,6 +1013,7 @@ class OperationTests(OperationTestBase):
Pony
.
objects
.
filter
(
pink
=
1
,
weight
=
3.55
)
.
delete
()
Pony
.
objects
.
filter
(
pink
=
1
,
weight
=
3.55
)
.
delete
()
Pony
.
objects
.
filter
(
weight
=
5
)
.
delete
()
Pony
.
objects
.
filter
(
weight
=
5
)
.
delete
()
operation
=
migrations
.
RunPython
(
inner_method
,
reverse_code
=
inner_method_reverse
)
operation
=
migrations
.
RunPython
(
inner_method
,
reverse_code
=
inner_method_reverse
)
self
.
assertEqual
(
operation
.
describe
(),
"Raw Python operation"
)
# Test the state alteration does nothing
# Test the state alteration does nothing
new_state
=
project_state
.
clone
()
new_state
=
project_state
.
clone
()
operation
.
state_forwards
(
"test_runpython"
,
new_state
)
operation
.
state_forwards
(
"test_runpython"
,
new_state
)
...
...
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