Re: [Django] #33607: PostgresIndex.create_sql() doesn't respect the using argument. (was: `PostgresIndex` uses `suffix` for both index name and method)

3 views
Skip to first unread message

Django

unread,
Mar 30, 2022, 7:07:11 AM3/30/22
to django-...@googlegroups.com
#33607: PostgresIndex.create_sql() doesn't respect the using argument.
--------------------------------------+------------------------------------
Reporter: Alexandru Mărășteanu | Owner: (none)
Type: Cleanup/optimization | Status: new
Component: contrib.postgres | Version: dev
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
--------------------------------------+------------------------------------
Changes (by Mariusz Felisiak):

* type: Bug => Cleanup/optimization
* stage: Unreviewed => Accepted


Comment:

Thanks for the report. `PostgresIndex` is an internal, undocumented API.
However, I agree that `create_sql()` should respect the `using` argument,
so the following diff should be sufficient:
{{{#!diff
diff --git a/django/contrib/postgres/indexes.py
b/django/contrib/postgres/indexes.py
index a0c03681b2..97377d8cb1 100644
--- a/django/contrib/postgres/indexes.py
+++ b/django/contrib/postgres/indexes.py
@@ -25,7 +25,7 @@ class PostgresIndex(Index):
def create_sql(self, model, schema_editor, using="", **kwargs):
self.check_supported(schema_editor)
statement = super().create_sql(
- model, schema_editor, using=" USING %s" % self.suffix,
**kwargs
+ model, schema_editor, using=" USING %s" % (using or
self.suffix), **kwargs
)
with_params = self.get_with_params()
if with_params:

}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/33607#comment:2>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Reply all
Reply to author
Forward
0 new messages