mirror of
https://github.com/django/django.git
synced 2025-03-31 19:46:42 +00:00
Fixed #35334 -- Removed supports_sequence_reset feature flag
This commit is contained in:
parent
b98271a6e4
commit
6775022253
@ -126,9 +126,6 @@ class BaseDatabaseFeatures:
|
|||||||
# in the SQL standard.
|
# in the SQL standard.
|
||||||
supports_tablespaces = False
|
supports_tablespaces = False
|
||||||
|
|
||||||
# Does the backend reset sequences between tests?
|
|
||||||
supports_sequence_reset = True
|
|
||||||
|
|
||||||
# Can the backend introspect the default value of a column?
|
# Can the backend introspect the default value of a column?
|
||||||
can_introspect_default = True
|
can_introspect_default = True
|
||||||
|
|
||||||
|
@ -30,7 +30,6 @@ class DatabaseFeatures(BaseDatabaseFeatures):
|
|||||||
truncates_names = True
|
truncates_names = True
|
||||||
supports_comments = True
|
supports_comments = True
|
||||||
supports_tablespaces = True
|
supports_tablespaces = True
|
||||||
supports_sequence_reset = False
|
|
||||||
can_introspect_materialized_views = True
|
can_introspect_materialized_views = True
|
||||||
atomic_transactions = False
|
atomic_transactions = False
|
||||||
nulls_order_largest = True
|
nulls_order_largest = True
|
||||||
|
@ -1157,15 +1157,14 @@ class TransactionTestCase(SimpleTestCase):
|
|||||||
|
|
||||||
def _reset_sequences(self, db_name):
|
def _reset_sequences(self, db_name):
|
||||||
conn = connections[db_name]
|
conn = connections[db_name]
|
||||||
if conn.features.supports_sequence_reset:
|
sql_list = conn.ops.sequence_reset_by_name_sql(
|
||||||
sql_list = conn.ops.sequence_reset_by_name_sql(
|
no_style(), conn.introspection.sequence_list()
|
||||||
no_style(), conn.introspection.sequence_list()
|
)
|
||||||
)
|
if sql_list:
|
||||||
if sql_list:
|
with transaction.atomic(using=db_name):
|
||||||
with transaction.atomic(using=db_name):
|
with conn.cursor() as cursor:
|
||||||
with conn.cursor() as cursor:
|
for sql in sql_list:
|
||||||
for sql in sql_list:
|
cursor.execute(sql)
|
||||||
cursor.execute(sql)
|
|
||||||
|
|
||||||
def _fixture_setup(self):
|
def _fixture_setup(self):
|
||||||
for db_name in self._databases_names(include_mirrors=False):
|
for db_name in self._databases_names(include_mirrors=False):
|
||||||
|
@ -225,11 +225,10 @@ class SqlFlushTests(TransactionTestCase):
|
|||||||
with transaction.atomic():
|
with transaction.atomic():
|
||||||
self.assertIs(Author.objects.exists(), False)
|
self.assertIs(Author.objects.exists(), False)
|
||||||
self.assertIs(Book.objects.exists(), False)
|
self.assertIs(Book.objects.exists(), False)
|
||||||
if connection.features.supports_sequence_reset:
|
author = Author.objects.create(name="F. Scott Fitzgerald")
|
||||||
author = Author.objects.create(name="F. Scott Fitzgerald")
|
self.assertEqual(author.pk, 1)
|
||||||
self.assertEqual(author.pk, 1)
|
book = Book.objects.create(author=author)
|
||||||
book = Book.objects.create(author=author)
|
self.assertEqual(book.pk, 1)
|
||||||
self.assertEqual(book.pk, 1)
|
|
||||||
|
|
||||||
|
|
||||||
class DeprecationTests(TestCase):
|
class DeprecationTests(TestCase):
|
||||||
|
@ -16,7 +16,7 @@ from django.conf import settings
|
|||||||
from django.core.exceptions import ImproperlyConfigured
|
from django.core.exceptions import ImproperlyConfigured
|
||||||
from django.core.management import call_command
|
from django.core.management import call_command
|
||||||
from django.core.management.base import CommandError, SystemCheckError
|
from django.core.management.base import CommandError, SystemCheckError
|
||||||
from django.test import SimpleTestCase, TransactionTestCase, skipUnlessDBFeature
|
from django.test import SimpleTestCase, TransactionTestCase
|
||||||
from django.test.runner import (
|
from django.test.runner import (
|
||||||
DiscoverRunner,
|
DiscoverRunner,
|
||||||
Shuffler,
|
Shuffler,
|
||||||
@ -943,7 +943,6 @@ class SetupDatabasesTests(unittest.TestCase):
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@skipUnlessDBFeature("supports_sequence_reset")
|
|
||||||
class AutoIncrementResetTest(TransactionTestCase):
|
class AutoIncrementResetTest(TransactionTestCase):
|
||||||
"""
|
"""
|
||||||
Creating the same models in different test methods receive the same PK
|
Creating the same models in different test methods receive the same PK
|
||||||
|
Loading…
x
Reference in New Issue
Block a user