summaryrefslogtreecommitdiff
path: root/tests/postgres_tests
diff options
context:
space:
mode:
authorAlexandru Mărășteanu <alexei@users.noreply.github.com>2022-04-15 23:00:28 +0300
committerGitHub <noreply@github.com>2022-04-15 22:00:28 +0200
commita1e4e86f923dc8387b0a9c3025bdd5d096a6ebb8 (patch)
tree11b0b3bedfddd640c461d9222cdba4133ec1fe16 /tests/postgres_tests
parentc72f6f36c13a21f6db3d4f85d2d3cec87bad45e6 (diff)
Fixed #33607 -- Made PostgresIndex.create_sql() respect the "using" argument.
Diffstat (limited to 'tests/postgres_tests')
-rw-r--r--tests/postgres_tests/test_indexes.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/tests/postgres_tests/test_indexes.py b/tests/postgres_tests/test_indexes.py
index 2f74203e8b..9da2f33ae8 100644
--- a/tests/postgres_tests/test_indexes.py
+++ b/tests/postgres_tests/test_indexes.py
@@ -8,6 +8,7 @@ from django.contrib.postgres.indexes import (
GistIndex,
HashIndex,
OpClass,
+ PostgresIndex,
SpGistIndex,
)
from django.db import NotSupportedError, connection
@@ -646,6 +647,21 @@ class SchemaTests(PostgreSQLTestCase):
editor.add_index(Scene, index)
self.assertNotIn(index_name, self.get_constraints(Scene._meta.db_table))
+ def test_custom_suffix(self):
+ class CustomSuffixIndex(PostgresIndex):
+ suffix = "sfx"
+
+ def create_sql(self, model, schema_editor, using="gin", **kwargs):
+ return super().create_sql(model, schema_editor, using=using, **kwargs)
+
+ index = CustomSuffixIndex(fields=["field"], name="custom_suffix_idx")
+ self.assertEqual(index.suffix, "sfx")
+ with connection.schema_editor() as editor:
+ self.assertIn(
+ " USING gin ",
+ str(index.create_sql(CharFieldModel, editor)),
+ )
+
def test_op_class(self):
index_name = "test_op_class"
index = Index(