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
9a88c6dd
Kaydet (Commit)
9a88c6dd
authored
Eki 25, 2018
tarafından
Sergey Fedoseev
Kaydeden (comit)
Tim Graham
Eki 25, 2018
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fixed #29827 -- Fixed reuse of test databases with --keepdb on MySQL.
Regression in
e1253bc2
.
üst
76b33670
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
16 additions
and
11 deletions
+16
-11
creation.py
django/db/backends/mysql/creation.py
+6
-11
2.1.3.txt
docs/releases/2.1.3.txt
+3
-0
test_creation.py
tests/backends/mysql/test_creation.py
+7
-0
No files found.
django/db/backends/mysql/creation.py
Dosyayı görüntüle @
9a88c6dd
...
@@ -19,17 +19,7 @@ class DatabaseCreation(BaseDatabaseCreation):
...
@@ -19,17 +19,7 @@ class DatabaseCreation(BaseDatabaseCreation):
def
_execute_create_test_db
(
self
,
cursor
,
parameters
,
keepdb
=
False
):
def
_execute_create_test_db
(
self
,
cursor
,
parameters
,
keepdb
=
False
):
try
:
try
:
if
keepdb
:
super
()
.
_execute_create_test_db
(
cursor
,
parameters
,
keepdb
)
# If the database should be kept, add "IF NOT EXISTS" to avoid
# "database exists" error, also temporarily disable "database
# exists" warning.
cursor
.
execute
(
'''
SET @_tmp_sql_notes := @@sql_notes, sql_notes = 0;
CREATE DATABASE IF NOT EXISTS
%(dbname)
s
%(suffix)
s;
SET sql_notes = @_tmp_sql_notes;
'''
%
parameters
)
else
:
super
()
.
_execute_create_test_db
(
cursor
,
parameters
,
keepdb
)
except
Exception
as
e
:
except
Exception
as
e
:
if
len
(
e
.
args
)
<
1
or
e
.
args
[
0
]
!=
1007
:
if
len
(
e
.
args
)
<
1
or
e
.
args
[
0
]
!=
1007
:
# All errors except "database exists" (1007) cancel tests.
# All errors except "database exists" (1007) cancel tests.
...
@@ -49,6 +39,9 @@ class DatabaseCreation(BaseDatabaseCreation):
...
@@ -49,6 +39,9 @@ class DatabaseCreation(BaseDatabaseCreation):
try
:
try
:
self
.
_execute_create_test_db
(
cursor
,
test_db_params
,
keepdb
)
self
.
_execute_create_test_db
(
cursor
,
test_db_params
,
keepdb
)
except
Exception
:
except
Exception
:
if
keepdb
:
# If the database should be kept, skip everything else.
return
try
:
try
:
if
verbosity
>=
1
:
if
verbosity
>=
1
:
self
.
log
(
'Destroying old test database for alias
%
s…'
%
(
self
.
log
(
'Destroying old test database for alias
%
s…'
%
(
...
@@ -59,7 +52,9 @@ class DatabaseCreation(BaseDatabaseCreation):
...
@@ -59,7 +52,9 @@ class DatabaseCreation(BaseDatabaseCreation):
except
Exception
as
e
:
except
Exception
as
e
:
self
.
log
(
'Got an error recreating the test database:
%
s'
%
e
)
self
.
log
(
'Got an error recreating the test database:
%
s'
%
e
)
sys
.
exit
(
2
)
sys
.
exit
(
2
)
self
.
_clone_db
(
source_database_name
,
target_database_name
)
def
_clone_db
(
self
,
source_database_name
,
target_database_name
):
dump_cmd
=
DatabaseClient
.
settings_to_cmd_args
(
self
.
connection
.
settings_dict
)
dump_cmd
=
DatabaseClient
.
settings_to_cmd_args
(
self
.
connection
.
settings_dict
)
dump_cmd
[
0
]
=
'mysqldump'
dump_cmd
[
0
]
=
'mysqldump'
dump_cmd
[
-
1
]
=
source_database_name
dump_cmd
[
-
1
]
=
source_database_name
...
...
docs/releases/2.1.3.txt
Dosyayı görüntüle @
9a88c6dd
...
@@ -14,3 +14,6 @@ Bugfixes
...
@@ -14,3 +14,6 @@ Bugfixes
* Fixed a regression in Django 1.11 where ``django-admin shell`` may hang
* Fixed a regression in Django 1.11 where ``django-admin shell`` may hang
on startup (:ticket:`29774`).
on startup (:ticket:`29774`).
* Fixed a regression in Django 2.0 where test databases aren't reused with
``manage.py test --keepdb`` on MySQL (:ticket:`29827`).
tests/backends/mysql/test_creation.py
Dosyayı görüntüle @
9a88c6dd
...
@@ -43,3 +43,10 @@ class DatabaseCreationTests(SimpleTestCase):
...
@@ -43,3 +43,10 @@ class DatabaseCreationTests(SimpleTestCase):
with
self
.
patch_test_db_creation
(
self
.
_execute_raise_access_denied
):
with
self
.
patch_test_db_creation
(
self
.
_execute_raise_access_denied
):
with
self
.
assertRaises
(
SystemExit
):
with
self
.
assertRaises
(
SystemExit
):
creation
.
_create_test_db
(
verbosity
=
0
,
autoclobber
=
False
,
keepdb
=
False
)
creation
.
_create_test_db
(
verbosity
=
0
,
autoclobber
=
False
,
keepdb
=
False
)
def
test_clone_test_db_database_exists
(
self
):
creation
=
DatabaseCreation
(
connection
)
with
self
.
patch_test_db_creation
(
self
.
_execute_raise_database_exists
):
with
mock
.
patch
.
object
(
DatabaseCreation
,
'_clone_db'
)
as
_clone_db
:
creation
.
_clone_test_db
(
'suffix'
,
verbosity
=
0
,
keepdb
=
True
)
_clone_db
.
assert_not_called
()
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