mirror of
https://github.com/django/django.git
synced 2025-09-18 16:30:01 +00:00
Fixed #33607 -- Made PostgresIndex.create_sql() respect the "using" argument.
This commit is contained in:
parent
c72f6f36c1
commit
a1e4e86f92
2 changed files with 17 additions and 1 deletions
|
@ -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(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue