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
Hide 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):
def
deconstruct
(
self
):
name
,
path
,
args
,
kwargs
=
super
(
ArrayField
,
self
)
.
deconstruct
()
path
=
'django.contrib.postgres.fields.ArrayField'
args
.
insert
(
0
,
self
.
base_field
)
kwargs
[
'size'
]
=
self
.
size
kwargs
.
update
({
'base_field'
:
self
.
base_field
,
'size'
:
self
.
size
,
})
return
name
,
path
,
args
,
kwargs
def
to_python
(
self
,
value
):
...
...
django/db/migrations/operations/fields.py
Dosyayı görüntüle @
912ad032
...
...
@@ -17,12 +17,16 @@ class AddField(Operation):
self
.
preserve_default
=
preserve_default
def
deconstruct
(
self
):
kwargs
=
{}
kwargs
=
{
'model_name'
:
self
.
model_name
,
'name'
:
self
.
name
,
'field'
:
self
.
field
,
}
if
self
.
preserve_default
is
not
True
:
kwargs
[
'preserve_default'
]
=
self
.
preserve_default
return
(
self
.
__class__
.
__name__
,
[
self
.
model_name
,
self
.
name
,
self
.
field
],
[],
kwargs
)
...
...
@@ -74,10 +78,14 @@ class RemoveField(Operation):
self
.
name
=
name
def
deconstruct
(
self
):
kwargs
=
{
'model_name'
:
self
.
model_name
,
'name'
:
self
.
name
,
}
return
(
self
.
__class__
.
__name__
,
[
self
.
model_name
,
self
.
name
],
{}
[],
kwargs
)
def
state_forwards
(
self
,
app_label
,
state
):
...
...
@@ -120,12 +128,16 @@ class AlterField(Operation):
self
.
preserve_default
=
preserve_default
def
deconstruct
(
self
):
kwargs
=
{}
kwargs
=
{
'model_name'
:
self
.
model_name
,
'name'
:
self
.
name
,
'field'
:
self
.
field
,
}
if
self
.
preserve_default
is
not
True
:
kwargs
[
'preserve_default'
]
=
self
.
preserve_default
return
(
self
.
__class__
.
__name__
,
[
self
.
model_name
,
self
.
name
,
self
.
field
],
[],
kwargs
)
...
...
@@ -183,10 +195,15 @@ class RenameField(Operation):
self
.
new_name
=
new_name
def
deconstruct
(
self
):
kwargs
=
{
'model_name'
:
self
.
model_name
,
'old_name'
:
self
.
old_name
,
'new_name'
:
self
.
new_name
,
}
return
(
self
.
__class__
.
__name__
,
[
self
.
model_name
,
self
.
old_name
,
self
.
new_name
],
{}
[],
kwargs
)
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):
self
.
bases
=
bases
or
(
models
.
Model
,)
def
deconstruct
(
self
):
kwargs
=
{}
kwargs
=
{
'name'
:
self
.
name
,
'fields'
:
self
.
fields
,
}
if
self
.
options
:
kwargs
[
'options'
]
=
self
.
options
if
self
.
bases
and
self
.
bases
!=
(
models
.
Model
,):
kwargs
[
'bases'
]
=
self
.
bases
return
(
self
.
__class__
.
__name__
,
[
self
.
name
,
self
.
fields
],
[],
kwargs
)
...
...
@@ -83,10 +86,13 @@ class DeleteModel(Operation):
self
.
name
=
name
def
deconstruct
(
self
):
kwargs
=
{
'name'
:
self
.
name
,
}
return
(
self
.
__class__
.
__name__
,
[
self
.
name
],
{}
[],
kwargs
)
def
state_forwards
(
self
,
app_label
,
state
):
...
...
@@ -121,10 +127,14 @@ class RenameModel(Operation):
self
.
new_name
=
new_name
def
deconstruct
(
self
):
kwargs
=
{
'old_name'
:
self
.
old_name
,
'new_name'
:
self
.
new_name
,
}
return
(
self
.
__class__
.
__name__
,
[
self
.
old_name
,
self
.
new_name
],
{}
[],
kwargs
)
def
state_forwards
(
self
,
app_label
,
state
):
...
...
@@ -214,10 +224,14 @@ class AlterModelTable(Operation):
self
.
table
=
table
def
deconstruct
(
self
):
kwargs
=
{
'name'
:
self
.
name
,
'table'
:
self
.
table
,
}
return
(
self
.
__class__
.
__name__
,
[
self
.
name
,
self
.
table
],
{}
[],
kwargs
)
def
state_forwards
(
self
,
app_label
,
state
):
...
...
@@ -266,10 +280,14 @@ class AlterUniqueTogether(Operation):
self
.
unique_together
=
set
(
tuple
(
cons
)
for
cons
in
unique_together
)
def
deconstruct
(
self
):
kwargs
=
{
'name'
:
self
.
name
,
'unique_together'
:
self
.
unique_together
,
}
return
(
self
.
__class__
.
__name__
,
[
self
.
name
,
self
.
unique_together
],
{}
[],
kwargs
)
def
state_forwards
(
self
,
app_label
,
state
):
...
...
@@ -311,10 +329,14 @@ class AlterIndexTogether(Operation):
self
.
index_together
=
set
(
tuple
(
cons
)
for
cons
in
index_together
)
def
deconstruct
(
self
):
kwargs
=
{
'name'
:
self
.
name
,
'index_together'
:
self
.
index_together
,
}
return
(
self
.
__class__
.
__name__
,
[
self
.
name
,
self
.
index_together
],
{}
[],
kwargs
)
def
state_forwards
(
self
,
app_label
,
state
):
...
...
@@ -353,10 +375,14 @@ class AlterOrderWithRespectTo(Operation):
self
.
order_with_respect_to
=
order_with_respect_to
def
deconstruct
(
self
):
kwargs
=
{
'name'
:
self
.
name
,
'order_with_respect_to'
:
self
.
order_with_respect_to
,
}
return
(
self
.
__class__
.
__name__
,
[
self
.
name
,
self
.
order_with_respect_to
],
{}
[],
kwargs
)
def
state_forwards
(
self
,
app_label
,
state
):
...
...
@@ -412,10 +438,14 @@ class AlterModelOptions(Operation):
self
.
options
=
options
def
deconstruct
(
self
):
kwargs
=
{
'name'
:
self
.
name
,
'options'
:
self
.
options
,
}
return
(
self
.
__class__
.
__name__
,
[
self
.
name
,
self
.
options
],
{}
[],
kwargs
)
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):
self
.
state_operations
=
state_operations
or
[]
def
deconstruct
(
self
):
kwargs
=
{}
kwargs
=
{
'sql'
:
self
.
sql
,
}
if
self
.
reverse_sql
is
not
None
:
kwargs
[
'reverse_sql'
]
=
self
.
reverse_sql
if
self
.
state_operations
:
kwargs
[
'state_operations'
]
=
self
.
state_operations
return
(
self
.
__class__
.
__name__
,
[
self
.
sql
],
[],
kwargs
)
...
...
@@ -137,14 +139,16 @@ class RunPython(Operation):
self
.
reverse_code
=
reverse_code
def
deconstruct
(
self
):
kwargs
=
{}
if
self
.
reverse_code
:
kwargs
=
{
'code'
:
self
.
code
,
}
if
self
.
reverse_code
is
not
None
:
kwargs
[
'reverse_code'
]
=
self
.
reverse_code
if
self
.
atomic
is
not
True
:
kwargs
[
'atomic'
]
=
self
.
atomic
return
(
self
.
__class__
.
__name__
,
[
self
.
code
],
[],
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
from
django.core
import
exceptions
,
serializers
from
django.core.management
import
call_command
from
django.db
import
models
,
IntegrityError
,
connection
from
django.db.migrations.writer
import
MigrationWriter
from
django
import
forms
from
django.test
import
TestCase
,
override_settings
from
django.utils
import
timezone
...
...
@@ -229,11 +228,6 @@ class TestMigrations(TestCase):
new
=
ArrayField
(
*
args
,
**
kwargs
)
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
=
{
"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