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
912ad032
Kaydet (Commit)
912ad032
authored
Kas 22, 2014
tarafından
Markus Holtermann
Kaydeden (comit)
Tim Graham
Kas 28, 2014
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fixed #23894 -- Made deconstruct methods favor kwargs over args
üst
e023ceb4
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
84 additions
and
37 deletions
+84
-37
array.py
django/contrib/postgres/fields/array.py
+4
-2
fields.py
django/db/migrations/operations/fields.py
+25
-8
models.py
django/db/migrations/operations/models.py
+46
-16
special.py
django/db/migrations/operations/special.py
+9
-5
test_operations.py
tests/migrations/test_operations.py
+0
-0
test_array.py
tests/postgres_tests/test_array.py
+0
-6
No files found.
django/contrib/postgres/fields/array.py
Dosyayı görüntüle @
912ad032
...
@@ -83,8 +83,10 @@ class ArrayField(Field):
...
@@ -83,8 +83,10 @@ class ArrayField(Field):
def
deconstruct
(
self
):
def
deconstruct
(
self
):
name
,
path
,
args
,
kwargs
=
super
(
ArrayField
,
self
)
.
deconstruct
()
name
,
path
,
args
,
kwargs
=
super
(
ArrayField
,
self
)
.
deconstruct
()
path
=
'django.contrib.postgres.fields.ArrayField'
path
=
'django.contrib.postgres.fields.ArrayField'
args
.
insert
(
0
,
self
.
base_field
)
kwargs
.
update
({
kwargs
[
'size'
]
=
self
.
size
'base_field'
:
self
.
base_field
,
'size'
:
self
.
size
,
})
return
name
,
path
,
args
,
kwargs
return
name
,
path
,
args
,
kwargs
def
to_python
(
self
,
value
):
def
to_python
(
self
,
value
):
...
...
django/db/migrations/operations/fields.py
Dosyayı görüntüle @
912ad032
...
@@ -17,12 +17,16 @@ class AddField(Operation):
...
@@ -17,12 +17,16 @@ class AddField(Operation):
self
.
preserve_default
=
preserve_default
self
.
preserve_default
=
preserve_default
def
deconstruct
(
self
):
def
deconstruct
(
self
):
kwargs
=
{}
kwargs
=
{
'model_name'
:
self
.
model_name
,
'name'
:
self
.
name
,
'field'
:
self
.
field
,
}
if
self
.
preserve_default
is
not
True
:
if
self
.
preserve_default
is
not
True
:
kwargs
[
'preserve_default'
]
=
self
.
preserve_default
kwargs
[
'preserve_default'
]
=
self
.
preserve_default
return
(
return
(
self
.
__class__
.
__name__
,
self
.
__class__
.
__name__
,
[
self
.
model_name
,
self
.
name
,
self
.
field
],
[],
kwargs
kwargs
)
)
...
@@ -74,10 +78,14 @@ class RemoveField(Operation):
...
@@ -74,10 +78,14 @@ class RemoveField(Operation):
self
.
name
=
name
self
.
name
=
name
def
deconstruct
(
self
):
def
deconstruct
(
self
):
kwargs
=
{
'model_name'
:
self
.
model_name
,
'name'
:
self
.
name
,
}
return
(
return
(
self
.
__class__
.
__name__
,
self
.
__class__
.
__name__
,
[
self
.
model_name
,
self
.
name
],
[],
{}
kwargs
)
)
def
state_forwards
(
self
,
app_label
,
state
):
def
state_forwards
(
self
,
app_label
,
state
):
...
@@ -120,12 +128,16 @@ class AlterField(Operation):
...
@@ -120,12 +128,16 @@ class AlterField(Operation):
self
.
preserve_default
=
preserve_default
self
.
preserve_default
=
preserve_default
def
deconstruct
(
self
):
def
deconstruct
(
self
):
kwargs
=
{}
kwargs
=
{
'model_name'
:
self
.
model_name
,
'name'
:
self
.
name
,
'field'
:
self
.
field
,
}
if
self
.
preserve_default
is
not
True
:
if
self
.
preserve_default
is
not
True
:
kwargs
[
'preserve_default'
]
=
self
.
preserve_default
kwargs
[
'preserve_default'
]
=
self
.
preserve_default
return
(
return
(
self
.
__class__
.
__name__
,
self
.
__class__
.
__name__
,
[
self
.
model_name
,
self
.
name
,
self
.
field
],
[],
kwargs
kwargs
)
)
...
@@ -183,10 +195,15 @@ class RenameField(Operation):
...
@@ -183,10 +195,15 @@ class RenameField(Operation):
self
.
new_name
=
new_name
self
.
new_name
=
new_name
def
deconstruct
(
self
):
def
deconstruct
(
self
):
kwargs
=
{
'model_name'
:
self
.
model_name
,
'old_name'
:
self
.
old_name
,
'new_name'
:
self
.
new_name
,
}
return
(
return
(
self
.
__class__
.
__name__
,
self
.
__class__
.
__name__
,
[
self
.
model_name
,
self
.
old_name
,
self
.
new_name
],
[],
{}
kwargs
)
)
def
state_forwards
(
self
,
app_label
,
state
):
def
state_forwards
(
self
,
app_label
,
state
):
...
...
django/db/migrations/operations/models.py
Dosyayı görüntüle @
912ad032
...
@@ -21,14 +21,17 @@ class CreateModel(Operation):
...
@@ -21,14 +21,17 @@ class CreateModel(Operation):
self
.
bases
=
bases
or
(
models
.
Model
,)
self
.
bases
=
bases
or
(
models
.
Model
,)
def
deconstruct
(
self
):
def
deconstruct
(
self
):
kwargs
=
{}
kwargs
=
{
'name'
:
self
.
name
,
'fields'
:
self
.
fields
,
}
if
self
.
options
:
if
self
.
options
:
kwargs
[
'options'
]
=
self
.
options
kwargs
[
'options'
]
=
self
.
options
if
self
.
bases
and
self
.
bases
!=
(
models
.
Model
,):
if
self
.
bases
and
self
.
bases
!=
(
models
.
Model
,):
kwargs
[
'bases'
]
=
self
.
bases
kwargs
[
'bases'
]
=
self
.
bases
return
(
return
(
self
.
__class__
.
__name__
,
self
.
__class__
.
__name__
,
[
self
.
name
,
self
.
fields
],
[],
kwargs
kwargs
)
)
...
@@ -83,10 +86,13 @@ class DeleteModel(Operation):
...
@@ -83,10 +86,13 @@ class DeleteModel(Operation):
self
.
name
=
name
self
.
name
=
name
def
deconstruct
(
self
):
def
deconstruct
(
self
):
kwargs
=
{
'name'
:
self
.
name
,
}
return
(
return
(
self
.
__class__
.
__name__
,
self
.
__class__
.
__name__
,
[
self
.
name
],
[],
{}
kwargs
)
)
def
state_forwards
(
self
,
app_label
,
state
):
def
state_forwards
(
self
,
app_label
,
state
):
...
@@ -121,10 +127,14 @@ class RenameModel(Operation):
...
@@ -121,10 +127,14 @@ class RenameModel(Operation):
self
.
new_name
=
new_name
self
.
new_name
=
new_name
def
deconstruct
(
self
):
def
deconstruct
(
self
):
kwargs
=
{
'old_name'
:
self
.
old_name
,
'new_name'
:
self
.
new_name
,
}
return
(
return
(
self
.
__class__
.
__name__
,
self
.
__class__
.
__name__
,
[
self
.
old_name
,
self
.
new_name
],
[],
{}
kwargs
)
)
def
state_forwards
(
self
,
app_label
,
state
):
def
state_forwards
(
self
,
app_label
,
state
):
...
@@ -214,10 +224,14 @@ class AlterModelTable(Operation):
...
@@ -214,10 +224,14 @@ class AlterModelTable(Operation):
self
.
table
=
table
self
.
table
=
table
def
deconstruct
(
self
):
def
deconstruct
(
self
):
kwargs
=
{
'name'
:
self
.
name
,
'table'
:
self
.
table
,
}
return
(
return
(
self
.
__class__
.
__name__
,
self
.
__class__
.
__name__
,
[
self
.
name
,
self
.
table
],
[],
{}
kwargs
)
)
def
state_forwards
(
self
,
app_label
,
state
):
def
state_forwards
(
self
,
app_label
,
state
):
...
@@ -266,10 +280,14 @@ class AlterUniqueTogether(Operation):
...
@@ -266,10 +280,14 @@ class AlterUniqueTogether(Operation):
self
.
unique_together
=
set
(
tuple
(
cons
)
for
cons
in
unique_together
)
self
.
unique_together
=
set
(
tuple
(
cons
)
for
cons
in
unique_together
)
def
deconstruct
(
self
):
def
deconstruct
(
self
):
kwargs
=
{
'name'
:
self
.
name
,
'unique_together'
:
self
.
unique_together
,
}
return
(
return
(
self
.
__class__
.
__name__
,
self
.
__class__
.
__name__
,
[
self
.
name
,
self
.
unique_together
],
[],
{}
kwargs
)
)
def
state_forwards
(
self
,
app_label
,
state
):
def
state_forwards
(
self
,
app_label
,
state
):
...
@@ -311,10 +329,14 @@ class AlterIndexTogether(Operation):
...
@@ -311,10 +329,14 @@ class AlterIndexTogether(Operation):
self
.
index_together
=
set
(
tuple
(
cons
)
for
cons
in
index_together
)
self
.
index_together
=
set
(
tuple
(
cons
)
for
cons
in
index_together
)
def
deconstruct
(
self
):
def
deconstruct
(
self
):
kwargs
=
{
'name'
:
self
.
name
,
'index_together'
:
self
.
index_together
,
}
return
(
return
(
self
.
__class__
.
__name__
,
self
.
__class__
.
__name__
,
[
self
.
name
,
self
.
index_together
],
[],
{}
kwargs
)
)
def
state_forwards
(
self
,
app_label
,
state
):
def
state_forwards
(
self
,
app_label
,
state
):
...
@@ -353,10 +375,14 @@ class AlterOrderWithRespectTo(Operation):
...
@@ -353,10 +375,14 @@ class AlterOrderWithRespectTo(Operation):
self
.
order_with_respect_to
=
order_with_respect_to
self
.
order_with_respect_to
=
order_with_respect_to
def
deconstruct
(
self
):
def
deconstruct
(
self
):
kwargs
=
{
'name'
:
self
.
name
,
'order_with_respect_to'
:
self
.
order_with_respect_to
,
}
return
(
return
(
self
.
__class__
.
__name__
,
self
.
__class__
.
__name__
,
[
self
.
name
,
self
.
order_with_respect_to
],
[],
{}
kwargs
)
)
def
state_forwards
(
self
,
app_label
,
state
):
def
state_forwards
(
self
,
app_label
,
state
):
...
@@ -412,10 +438,14 @@ class AlterModelOptions(Operation):
...
@@ -412,10 +438,14 @@ class AlterModelOptions(Operation):
self
.
options
=
options
self
.
options
=
options
def
deconstruct
(
self
):
def
deconstruct
(
self
):
kwargs
=
{
'name'
:
self
.
name
,
'options'
:
self
.
options
,
}
return
(
return
(
self
.
__class__
.
__name__
,
self
.
__class__
.
__name__
,
[
self
.
name
,
self
.
options
],
[],
{}
kwargs
)
)
def
state_forwards
(
self
,
app_label
,
state
):
def
state_forwards
(
self
,
app_label
,
state
):
...
...
django/db/migrations/operations/special.py
Dosyayı görüntüle @
912ad032
...
@@ -68,14 +68,16 @@ class RunSQL(Operation):
...
@@ -68,14 +68,16 @@ class RunSQL(Operation):
self
.
state_operations
=
state_operations
or
[]
self
.
state_operations
=
state_operations
or
[]
def
deconstruct
(
self
):
def
deconstruct
(
self
):
kwargs
=
{}
kwargs
=
{
'sql'
:
self
.
sql
,
}
if
self
.
reverse_sql
is
not
None
:
if
self
.
reverse_sql
is
not
None
:
kwargs
[
'reverse_sql'
]
=
self
.
reverse_sql
kwargs
[
'reverse_sql'
]
=
self
.
reverse_sql
if
self
.
state_operations
:
if
self
.
state_operations
:
kwargs
[
'state_operations'
]
=
self
.
state_operations
kwargs
[
'state_operations'
]
=
self
.
state_operations
return
(
return
(
self
.
__class__
.
__name__
,
self
.
__class__
.
__name__
,
[
self
.
sql
],
[],
kwargs
kwargs
)
)
...
@@ -137,14 +139,16 @@ class RunPython(Operation):
...
@@ -137,14 +139,16 @@ class RunPython(Operation):
self
.
reverse_code
=
reverse_code
self
.
reverse_code
=
reverse_code
def
deconstruct
(
self
):
def
deconstruct
(
self
):
kwargs
=
{}
kwargs
=
{
if
self
.
reverse_code
:
'code'
:
self
.
code
,
}
if
self
.
reverse_code
is
not
None
:
kwargs
[
'reverse_code'
]
=
self
.
reverse_code
kwargs
[
'reverse_code'
]
=
self
.
reverse_code
if
self
.
atomic
is
not
True
:
if
self
.
atomic
is
not
True
:
kwargs
[
'atomic'
]
=
self
.
atomic
kwargs
[
'atomic'
]
=
self
.
atomic
return
(
return
(
self
.
__class__
.
__name__
,
self
.
__class__
.
__name__
,
[
self
.
code
],
[],
kwargs
kwargs
)
)
...
...
tests/migrations/test_operations.py
Dosyayı görüntüle @
912ad032
This diff is collapsed.
Click to expand it.
tests/postgres_tests/test_array.py
Dosyayı görüntüle @
912ad032
...
@@ -6,7 +6,6 @@ from django.contrib.postgres.forms import SimpleArrayField, SplitArrayField
...
@@ -6,7 +6,6 @@ from django.contrib.postgres.forms import SimpleArrayField, SplitArrayField
from
django.core
import
exceptions
,
serializers
from
django.core
import
exceptions
,
serializers
from
django.core.management
import
call_command
from
django.core.management
import
call_command
from
django.db
import
models
,
IntegrityError
,
connection
from
django.db
import
models
,
IntegrityError
,
connection
from
django.db.migrations.writer
import
MigrationWriter
from
django
import
forms
from
django
import
forms
from
django.test
import
TestCase
,
override_settings
from
django.test
import
TestCase
,
override_settings
from
django.utils
import
timezone
from
django.utils
import
timezone
...
@@ -229,11 +228,6 @@ class TestMigrations(TestCase):
...
@@ -229,11 +228,6 @@ class TestMigrations(TestCase):
new
=
ArrayField
(
*
args
,
**
kwargs
)
new
=
ArrayField
(
*
args
,
**
kwargs
)
self
.
assertEqual
(
new
.
base_field
.
max_length
,
field
.
base_field
.
max_length
)
self
.
assertEqual
(
new
.
base_field
.
max_length
,
field
.
base_field
.
max_length
)
def
test_makemigrations
(
self
):
field
=
ArrayField
(
models
.
CharField
(
max_length
=
20
))
statement
,
imports
=
MigrationWriter
.
serialize
(
field
)
self
.
assertEqual
(
statement
,
'django.contrib.postgres.fields.ArrayField(models.CharField(max_length=20), size=None)'
)
@override_settings
(
MIGRATION_MODULES
=
{
@override_settings
(
MIGRATION_MODULES
=
{
"postgres_tests"
:
"postgres_tests.array_default_migrations"
,
"postgres_tests"
:
"postgres_tests.array_default_migrations"
,
})
})
...
...
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