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
d4305a15
Kaydet (Commit)
d4305a15
authored
Haz 16, 2014
tarafından
Andrew Godwin
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
[1.7.x] Fixed #22844: Duplicate SQL for SQLite FKs
üst
44a50603
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
46 additions
and
1 deletion
+46
-1
schema.py
django/db/backends/sqlite3/schema.py
+3
-1
test_operations.py
tests/migrations/test_operations.py
+43
-0
No files found.
django/db/backends/sqlite3/schema.py
Dosyayı görüntüle @
d4305a15
...
@@ -104,7 +104,9 @@ class DatabaseSchemaEditor(BaseDatabaseSchemaEditor):
...
@@ -104,7 +104,9 @@ class DatabaseSchemaEditor(BaseDatabaseSchemaEditor):
body
[
'__module__'
]
=
model
.
__module__
body
[
'__module__'
]
=
model
.
__module__
temp_model
=
type
(
model
.
_meta
.
object_name
,
model
.
__bases__
,
body
)
temp_model
=
type
(
model
.
_meta
.
object_name
,
model
.
__bases__
,
body
)
# Create a new table with that format
# Create a new table with that format. We remove things from the
# deferred SQL that match our table name, too
self
.
deferred_sql
=
[
x
for
x
in
self
.
deferred_sql
if
model
.
_meta
.
db_table
not
in
x
]
self
.
create_model
(
temp_model
)
self
.
create_model
(
temp_model
)
# Copy data from the old table
# Copy data from the old table
field_maps
=
list
(
mapping
.
items
())
field_maps
=
list
(
mapping
.
items
())
...
...
tests/migrations/test_operations.py
Dosyayı görüntüle @
d4305a15
...
@@ -156,6 +156,49 @@ class OperationTests(MigrationTestBase):
...
@@ -156,6 +156,49 @@ class OperationTests(MigrationTestBase):
self
.
assertEqual
(
len
(
definition
[
2
]),
0
)
self
.
assertEqual
(
len
(
definition
[
2
]),
0
)
self
.
assertEqual
(
definition
[
1
][
0
],
"Pony"
)
self
.
assertEqual
(
definition
[
1
][
0
],
"Pony"
)
def
test_create_model_with_unique_after
(
self
):
"""
Tests the CreateModel operation directly followed by an
AlterUniqueTogether (bug #22844 - sqlite remake issues)
"""
operation1
=
migrations
.
CreateModel
(
"Pony"
,
[
(
"id"
,
models
.
AutoField
(
primary_key
=
True
)),
(
"pink"
,
models
.
IntegerField
(
default
=
1
)),
],
)
operation2
=
migrations
.
CreateModel
(
"Rider"
,
[
(
"id"
,
models
.
AutoField
(
primary_key
=
True
)),
(
"number"
,
models
.
IntegerField
(
default
=
1
)),
(
"pony"
,
models
.
ForeignKey
(
"test_crmoua.Pony"
)),
],
)
operation3
=
migrations
.
AlterUniqueTogether
(
"Rider"
,
[
(
"number"
,
"pony"
),
],
)
# Test the database alteration
project_state
=
ProjectState
()
self
.
assertTableNotExists
(
"test_crmoua_pony"
)
self
.
assertTableNotExists
(
"test_crmoua_rider"
)
with
connection
.
schema_editor
()
as
editor
:
new_state
=
project_state
.
clone
()
operation1
.
state_forwards
(
"test_crmoua"
,
new_state
)
operation1
.
database_forwards
(
"test_crmoua"
,
editor
,
project_state
,
new_state
)
project_state
,
new_state
=
new_state
,
new_state
.
clone
()
operation2
.
state_forwards
(
"test_crmoua"
,
new_state
)
operation2
.
database_forwards
(
"test_crmoua"
,
editor
,
project_state
,
new_state
)
project_state
,
new_state
=
new_state
,
new_state
.
clone
()
operation3
.
state_forwards
(
"test_crmoua"
,
new_state
)
operation3
.
database_forwards
(
"test_crmoua"
,
editor
,
project_state
,
new_state
)
self
.
assertTableExists
(
"test_crmoua_pony"
)
self
.
assertTableExists
(
"test_crmoua_rider"
)
def
test_create_model_m2m
(
self
):
def
test_create_model_m2m
(
self
):
"""
"""
Test the creation of a model with a ManyToMany field and the
Test the creation of a model with a ManyToMany field and the
...
...
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