mirror of
https://github.com/django/django.git
synced 2024-12-22 17:16:24 +00:00
Refs #29547 -- Corrected SQLite's supports_partial_indexes feature flag.
This commit is contained in:
parent
c5b58d7767
commit
e5b8626c0e
@ -34,7 +34,7 @@ class DatabaseFeatures(BaseDatabaseFeatures):
|
||||
supports_cast_with_precision = False
|
||||
time_cast_precision = 3
|
||||
can_release_savepoints = True
|
||||
supports_partial_indexes = Database.version_info >= (3, 8, 0)
|
||||
supports_partial_indexes = Database.sqlite_version_info >= (3, 8, 0)
|
||||
# Is "ALTER TABLE ... RENAME COLUMN" supported?
|
||||
can_alter_table_rename_column = Database.sqlite_version_info >= (3, 25, 0)
|
||||
supports_parentheses_in_compound = False
|
||||
|
@ -9,6 +9,7 @@ from django.db.models.query_utils import Q
|
||||
from django.test import (
|
||||
TestCase, TransactionTestCase, skipIfDBFeature, skipUnlessDBFeature,
|
||||
)
|
||||
from django.test.utils import override_settings
|
||||
from django.utils import timezone
|
||||
|
||||
from .models import (
|
||||
@ -237,8 +238,11 @@ class SchemaIndexesMySQLTests(TransactionTestCase):
|
||||
|
||||
|
||||
@skipUnlessDBFeature('supports_partial_indexes')
|
||||
class PartialIndexTests(TestCase):
|
||||
# SQLite doesn't support timezone-aware datetimes when USE_TZ is False.
|
||||
@override_settings(USE_TZ=True)
|
||||
class PartialIndexTests(TransactionTestCase):
|
||||
# Schema editor is used to create the index to test that it works.
|
||||
available_apps = ['indexes']
|
||||
|
||||
def test_partial_index(self):
|
||||
with connection.schema_editor() as editor:
|
||||
@ -263,6 +267,7 @@ class PartialIndexTests(TestCase):
|
||||
self.assertIn(index.name, connection.introspection.get_constraints(
|
||||
cursor=connection.cursor(), table_name=Article._meta.db_table,
|
||||
))
|
||||
editor.remove_index(index=index, model=Article)
|
||||
|
||||
def test_integer_restriction_partial(self):
|
||||
with connection.schema_editor() as editor:
|
||||
@ -279,6 +284,7 @@ class PartialIndexTests(TestCase):
|
||||
self.assertIn(index.name, connection.introspection.get_constraints(
|
||||
cursor=connection.cursor(), table_name=Article._meta.db_table,
|
||||
))
|
||||
editor.remove_index(index=index, model=Article)
|
||||
|
||||
def test_boolean_restriction_partial(self):
|
||||
with connection.schema_editor() as editor:
|
||||
@ -295,6 +301,7 @@ class PartialIndexTests(TestCase):
|
||||
self.assertIn(index.name, connection.introspection.get_constraints(
|
||||
cursor=connection.cursor(), table_name=Article._meta.db_table,
|
||||
))
|
||||
editor.remove_index(index=index, model=Article)
|
||||
|
||||
def test_multiple_conditions(self):
|
||||
with connection.schema_editor() as editor:
|
||||
@ -323,6 +330,7 @@ class PartialIndexTests(TestCase):
|
||||
self.assertIn(index.name, connection.introspection.get_constraints(
|
||||
cursor=connection.cursor(), table_name=Article._meta.db_table,
|
||||
))
|
||||
editor.remove_index(index=index, model=Article)
|
||||
|
||||
def test_is_null_condition(self):
|
||||
with connection.schema_editor() as editor:
|
||||
@ -339,3 +347,4 @@ class PartialIndexTests(TestCase):
|
||||
self.assertIn(index.name, connection.introspection.get_constraints(
|
||||
cursor=connection.cursor(), table_name=Article._meta.db_table,
|
||||
))
|
||||
editor.remove_index(index=index, model=Article)
|
||||
|
Loading…
Reference in New Issue
Block a user