Fixed #31477 -- Removed "using" argument from DatabaseOperations.execute_sql_flush().
This commit is contained in:
parent
661e39c8d5
commit
5673d4b102
|
@ -60,7 +60,7 @@ Are you sure you want to do this?
|
||||||
|
|
||||||
if confirm == 'yes':
|
if confirm == 'yes':
|
||||||
try:
|
try:
|
||||||
connection.ops.execute_sql_flush(database, sql_list)
|
connection.ops.execute_sql_flush(sql_list)
|
||||||
except Exception as exc:
|
except Exception as exc:
|
||||||
raise CommandError(
|
raise CommandError(
|
||||||
"Database %s couldn't be flushed. Possible reasons:\n"
|
"Database %s couldn't be flushed. Possible reasons:\n"
|
||||||
|
|
|
@ -400,9 +400,12 @@ class BaseDatabaseOperations:
|
||||||
"""
|
"""
|
||||||
raise NotImplementedError('subclasses of BaseDatabaseOperations must provide a sql_flush() method')
|
raise NotImplementedError('subclasses of BaseDatabaseOperations must provide a sql_flush() method')
|
||||||
|
|
||||||
def execute_sql_flush(self, using, sql_list):
|
def execute_sql_flush(self, sql_list):
|
||||||
"""Execute a list of SQL statements to flush the database."""
|
"""Execute a list of SQL statements to flush the database."""
|
||||||
with transaction.atomic(using=using, savepoint=self.connection.features.can_rollback_ddl):
|
with transaction.atomic(
|
||||||
|
using=self.connection.alias,
|
||||||
|
savepoint=self.connection.features.can_rollback_ddl,
|
||||||
|
):
|
||||||
with self.connection.cursor() as cursor:
|
with self.connection.cursor() as cursor:
|
||||||
for sql in sql_list:
|
for sql in sql_list:
|
||||||
cursor.execute(sql)
|
cursor.execute(sql)
|
||||||
|
|
|
@ -526,6 +526,10 @@ backends.
|
||||||
* The ``allow_cascade`` argument of ``DatabaseOperations.sql_flush()`` is now a
|
* The ``allow_cascade`` argument of ``DatabaseOperations.sql_flush()`` is now a
|
||||||
keyword-only argument.
|
keyword-only argument.
|
||||||
|
|
||||||
|
* The ``using`` positional argument of
|
||||||
|
``DatabaseOperations.execute_sql_flush()`` is removed. The method now uses
|
||||||
|
the database of the called instance.
|
||||||
|
|
||||||
Dropped support for MariaDB 10.1
|
Dropped support for MariaDB 10.1
|
||||||
--------------------------------
|
--------------------------------
|
||||||
|
|
||||||
|
|
|
@ -172,7 +172,7 @@ class SqlFlushTests(TransactionTestCase):
|
||||||
reset_sequences=True,
|
reset_sequences=True,
|
||||||
allow_cascade=True,
|
allow_cascade=True,
|
||||||
)
|
)
|
||||||
connection.ops.execute_sql_flush(connection.alias, sql_list)
|
connection.ops.execute_sql_flush(sql_list)
|
||||||
|
|
||||||
with transaction.atomic():
|
with transaction.atomic():
|
||||||
self.assertIs(Author.objects.exists(), False)
|
self.assertIs(Author.objects.exists(), False)
|
||||||
|
|
|
@ -162,7 +162,7 @@ class LongNameTest(TransactionTestCase):
|
||||||
VLM_m2m._meta.db_table,
|
VLM_m2m._meta.db_table,
|
||||||
]
|
]
|
||||||
sql_list = connection.ops.sql_flush(no_style(), tables, reset_sequences=True)
|
sql_list = connection.ops.sql_flush(no_style(), tables, reset_sequences=True)
|
||||||
connection.ops.execute_sql_flush(connection.alias, sql_list)
|
connection.ops.execute_sql_flush(sql_list)
|
||||||
|
|
||||||
|
|
||||||
class SequenceResetTest(TestCase):
|
class SequenceResetTest(TestCase):
|
||||||
|
|
Loading…
Reference in New Issue