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
8eb56f3c
Kaydet (Commit)
8eb56f3c
authored
Kas 18, 2016
tarafından
Lex Berezhny
Kaydeden (comit)
Tim Graham
Kas 30, 2016
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fixed #27507 -- Used SchemaEditor.execute() to run deferred_sql in migrate's sync_apps().
üst
71609a5b
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
27 additions
and
2 deletions
+27
-2
migrate.py
django/core/management/commands/migrate.py
+3
-2
__init__.py
...ns/migrations_test_apps/unmigrated_app_syncdb/__init__.py
+0
-0
models.py
...ions/migrations_test_apps/unmigrated_app_syncdb/models.py
+9
-0
test_commands.py
tests/migrations/test_commands.py
+15
-0
No files found.
django/core/management/commands/migrate.py
Dosyayı görüntüle @
8eb56f3c
...
...
@@ -312,8 +312,9 @@ class Command(BaseCommand):
if
self
.
verbosity
>=
1
:
self
.
stdout
.
write
(
" Running deferred SQL...
\n
"
)
for
statement
in
deferred_sql
:
cursor
.
execute
(
statement
)
with
connection
.
schema_editor
()
as
editor
:
for
statement
in
deferred_sql
:
editor
.
execute
(
statement
)
finally
:
cursor
.
close
()
...
...
tests/migrations/migrations_test_apps/unmigrated_app_syncdb/__init__.py
0 → 100644
Dosyayı görüntüle @
8eb56f3c
tests/migrations/migrations_test_apps/unmigrated_app_syncdb/models.py
0 → 100644
Dosyayı görüntüle @
8eb56f3c
from
django.db
import
models
class
Classroom
(
models
.
Model
):
pass
class
Lesson
(
models
.
Model
):
classroom
=
models
.
ForeignKey
(
Classroom
,
on_delete
=
models
.
CASCADE
)
tests/migrations/test_commands.py
Dosyayı görüntüle @
8eb56f3c
...
...
@@ -12,6 +12,7 @@ from django.core.management import CommandError, call_command
from
django.db
import
(
ConnectionHandler
,
DatabaseError
,
connection
,
connections
,
models
,
)
from
django.db.backends.base.schema
import
BaseDatabaseSchemaEditor
from
django.db.migrations.exceptions
import
(
InconsistentMigrationHistory
,
MigrationSchemaMissing
,
)
...
...
@@ -461,6 +462,20 @@ class MigrateTests(MigrationTestBase):
# to avoid problems in subsequent tests.
del
apps
.
_pending_operations
[(
'migrations'
,
'tribble'
)]
@override_settings
(
INSTALLED_APPS
=
[
'migrations.migrations_test_apps.unmigrated_app_syncdb'
])
def
test_migrate_syncdb_deferred_sql_executed_with_schemaeditor
(
self
):
"""
For an app without migrations, editor.execute() is used for executing
the syncdb deferred SQL.
"""
with
mock
.
patch
.
object
(
BaseDatabaseSchemaEditor
,
'execute'
)
as
execute
:
call_command
(
'migrate'
,
run_syncdb
=
True
,
verbosity
=
0
)
create_table_count
=
len
([
call
for
call
in
execute
.
mock_calls
if
'CREATE TABLE'
in
str
(
call
)])
self
.
assertEqual
(
create_table_count
,
2
)
# There's at least one deferred SQL for creating the foreign key
# index.
self
.
assertGreater
(
len
(
execute
.
mock_calls
),
2
)
@override_settings
(
MIGRATION_MODULES
=
{
"migrations"
:
"migrations.test_migrations_squashed"
})
def
test_migrate_record_replaced
(
self
):
"""
...
...
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