mirror of
https://github.com/django/django.git
synced 2025-10-24 06:06:09 +00:00
Fixed #33717 -- Dropped support for PostgreSQL 11.
This commit is contained in:
@@ -845,7 +845,6 @@ class ExclusionConstraintTests(PostgreSQLTestCase):
|
||||
RangesModel.objects.create(ints=(10, 19))
|
||||
RangesModel.objects.create(ints=(51, 60))
|
||||
|
||||
@skipUnlessDBFeature("supports_covering_gist_indexes")
|
||||
def test_range_adjacent_gist_include(self):
|
||||
constraint_name = "ints_adjacent_gist_include"
|
||||
self.assertNotIn(
|
||||
@@ -887,7 +886,6 @@ class ExclusionConstraintTests(PostgreSQLTestCase):
|
||||
RangesModel.objects.create(ints=(10, 19))
|
||||
RangesModel.objects.create(ints=(51, 60))
|
||||
|
||||
@skipUnlessDBFeature("supports_covering_gist_indexes")
|
||||
def test_range_adjacent_gist_include_condition(self):
|
||||
constraint_name = "ints_adjacent_gist_include_condition"
|
||||
self.assertNotIn(
|
||||
@@ -921,7 +919,6 @@ class ExclusionConstraintTests(PostgreSQLTestCase):
|
||||
editor.add_constraint(RangesModel, constraint)
|
||||
self.assertIn(constraint_name, self.get_constraints(RangesModel._meta.db_table))
|
||||
|
||||
@skipUnlessDBFeature("supports_covering_gist_indexes")
|
||||
def test_range_adjacent_gist_include_deferrable(self):
|
||||
constraint_name = "ints_adjacent_gist_include_deferrable"
|
||||
self.assertNotIn(
|
||||
@@ -955,27 +952,6 @@ class ExclusionConstraintTests(PostgreSQLTestCase):
|
||||
editor.add_constraint(RangesModel, constraint)
|
||||
self.assertIn(constraint_name, self.get_constraints(RangesModel._meta.db_table))
|
||||
|
||||
def test_gist_include_not_supported(self):
|
||||
constraint_name = "ints_adjacent_gist_include_not_supported"
|
||||
constraint = ExclusionConstraint(
|
||||
name=constraint_name,
|
||||
expressions=[("ints", RangeOperators.ADJACENT_TO)],
|
||||
index_type="gist",
|
||||
include=["id"],
|
||||
)
|
||||
msg = (
|
||||
"Covering exclusion constraints using a GiST index require "
|
||||
"PostgreSQL 12+."
|
||||
)
|
||||
with connection.schema_editor() as editor:
|
||||
with mock.patch(
|
||||
"django.db.backends.postgresql.features.DatabaseFeatures."
|
||||
"supports_covering_gist_indexes",
|
||||
False,
|
||||
):
|
||||
with self.assertRaisesMessage(NotSupportedError, msg):
|
||||
editor.add_constraint(RangesModel, constraint)
|
||||
|
||||
def test_spgist_include_not_supported(self):
|
||||
constraint_name = "ints_adjacent_spgist_include_not_supported"
|
||||
constraint = ExclusionConstraint(
|
||||
@@ -1062,7 +1038,6 @@ class ExclusionConstraintTests(PostgreSQLTestCase):
|
||||
editor.add_constraint(RangesModel, constraint)
|
||||
self.assertIn(constraint_name, self.get_constraints(RangesModel._meta.db_table))
|
||||
|
||||
@skipUnlessDBFeature("supports_covering_gist_indexes")
|
||||
def test_range_adjacent_gist_opclass_include(self):
|
||||
constraint_name = "ints_adjacent_gist_opclass_include"
|
||||
self.assertNotIn(
|
||||
@@ -1210,7 +1185,6 @@ class ExclusionConstraintOpclassesDepracationTests(PostgreSQLTestCase):
|
||||
self.assertIn(constraint_name, self.get_constraints(RangesModel._meta.db_table))
|
||||
|
||||
@ignore_warnings(category=RemovedInDjango50Warning)
|
||||
@skipUnlessDBFeature("supports_covering_gist_indexes")
|
||||
def test_range_adjacent_gist_opclasses_include(self):
|
||||
constraint_name = "ints_adjacent_gist_opclasses_include"
|
||||
self.assertNotIn(
|
||||
|
||||
@@ -505,7 +505,6 @@ class SchemaTests(PostgreSQLTestCase):
|
||||
index_name, self.get_constraints(CharFieldModel._meta.db_table)
|
||||
)
|
||||
|
||||
@skipUnlessDBFeature("supports_covering_gist_indexes")
|
||||
def test_gist_include(self):
|
||||
index_name = "scene_gist_include_setting"
|
||||
index = GistIndex(name=index_name, fields=["scene"], include=["setting"])
|
||||
@@ -519,20 +518,6 @@ class SchemaTests(PostgreSQLTestCase):
|
||||
editor.remove_index(Scene, index)
|
||||
self.assertNotIn(index_name, self.get_constraints(Scene._meta.db_table))
|
||||
|
||||
def test_gist_include_not_supported(self):
|
||||
index_name = "gist_include_exception"
|
||||
index = GistIndex(fields=["scene"], name=index_name, include=["setting"])
|
||||
msg = "Covering GiST indexes require PostgreSQL 12+."
|
||||
with self.assertRaisesMessage(NotSupportedError, msg):
|
||||
with mock.patch(
|
||||
"django.db.backends.postgresql.features.DatabaseFeatures."
|
||||
"supports_covering_gist_indexes",
|
||||
False,
|
||||
):
|
||||
with connection.schema_editor() as editor:
|
||||
editor.add_index(Scene, index)
|
||||
self.assertNotIn(index_name, self.get_constraints(Scene._meta.db_table))
|
||||
|
||||
def test_tsvector_op_class_gist_index(self):
|
||||
index_name = "tsvector_op_class_gist"
|
||||
index = GistIndex(
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import unittest
|
||||
from unittest import mock
|
||||
|
||||
from migrations.test_base import OperationTestBase
|
||||
|
||||
@@ -7,7 +6,7 @@ from django.db import IntegrityError, NotSupportedError, connection, transaction
|
||||
from django.db.migrations.state import ProjectState
|
||||
from django.db.models import CheckConstraint, Index, Q, UniqueConstraint
|
||||
from django.db.utils import ProgrammingError
|
||||
from django.test import modify_settings, override_settings, skipUnlessDBFeature
|
||||
from django.test import modify_settings, override_settings
|
||||
from django.test.utils import CaptureQueriesContext
|
||||
|
||||
from . import PostgreSQLTestCase
|
||||
@@ -318,7 +317,6 @@ class CreateCollationTests(PostgreSQLTestCase):
|
||||
self.assertEqual(args, [])
|
||||
self.assertEqual(kwargs, {"name": "C_test", "locale": "C"})
|
||||
|
||||
@skipUnlessDBFeature("supports_non_deterministic_collations")
|
||||
def test_create_non_deterministic_collation(self):
|
||||
operation = CreateCollation(
|
||||
"case_insensitive_test",
|
||||
@@ -383,27 +381,6 @@ class CreateCollationTests(PostgreSQLTestCase):
|
||||
self.assertEqual(len(captured_queries), 1)
|
||||
self.assertIn("DROP COLLATION", captured_queries[0]["sql"])
|
||||
|
||||
def test_nondeterministic_collation_not_supported(self):
|
||||
operation = CreateCollation(
|
||||
"case_insensitive_test",
|
||||
provider="icu",
|
||||
locale="und-u-ks-level2",
|
||||
deterministic=False,
|
||||
)
|
||||
project_state = ProjectState()
|
||||
new_state = project_state.clone()
|
||||
msg = "Non-deterministic collations require PostgreSQL 12+."
|
||||
with connection.schema_editor(atomic=False) as editor:
|
||||
with mock.patch(
|
||||
"django.db.backends.postgresql.features.DatabaseFeatures."
|
||||
"supports_non_deterministic_collations",
|
||||
False,
|
||||
):
|
||||
with self.assertRaisesMessage(NotSupportedError, msg):
|
||||
operation.database_forwards(
|
||||
self.app_label, editor, project_state, new_state
|
||||
)
|
||||
|
||||
|
||||
@unittest.skipUnless(connection.vendor == "postgresql", "PostgreSQL specific tests.")
|
||||
class RemoveCollationTests(PostgreSQLTestCase):
|
||||
|
||||
@@ -46,8 +46,7 @@ class TrigramTest(PostgreSQLTestCase):
|
||||
|
||||
def test_trigram_similarity(self):
|
||||
search = "Bat sat on cat."
|
||||
# Round result of similarity because PostgreSQL 12+ uses greater
|
||||
# precision.
|
||||
# Round result of similarity because PostgreSQL uses greater precision.
|
||||
self.assertQuerysetEqual(
|
||||
self.Model.objects.filter(
|
||||
field__trigram_similar=search,
|
||||
@@ -77,8 +76,7 @@ class TrigramTest(PostgreSQLTestCase):
|
||||
)
|
||||
|
||||
def test_trigram_similarity_alternate(self):
|
||||
# Round result of distance because PostgreSQL 12+ uses greater
|
||||
# precision.
|
||||
# Round result of distance because PostgreSQL uses greater precision.
|
||||
self.assertQuerysetEqual(
|
||||
self.Model.objects.annotate(
|
||||
distance=TrigramDistance("field", "Bat sat on cat."),
|
||||
|
||||
Reference in New Issue
Block a user