summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Charette <charette.s@gmail.com>2018-12-21 18:06:16 -0500
committerTim Graham <timograham@gmail.com>2018-12-22 14:51:59 -0500
commite5b8626c0eb223cc3d643163882c5902c40ec972 (patch)
tree3f22348db39d13126b9e9adb9ebb865bb64108a7
parentc5b58d77673b9f9d3a90e1c6a5bf15dce76f3d45 (diff)
Refs #29547 -- Corrected SQLite's supports_partial_indexes feature flag.
-rw-r--r--django/db/backends/sqlite3/features.py2
-rw-r--r--tests/indexes/tests.py11
2 files changed, 11 insertions, 2 deletions
diff --git a/django/db/backends/sqlite3/features.py b/django/db/backends/sqlite3/features.py
index 685c60a443..1a31aa844d 100644
--- a/django/db/backends/sqlite3/features.py
+++ b/django/db/backends/sqlite3/features.py
@@ -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
diff --git a/tests/indexes/tests.py b/tests/indexes/tests.py
index ae79f375f5..ef81f6ab9b 100644
--- a/tests/indexes/tests.py
+++ b/tests/indexes/tests.py
@@ -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)