#30846: PostGIS not respecting index names
--------------------------------------------------+------------------------
Reporter: Thomas Steen Rasmussen | Owner: nobody
Type: Bug | Status: new
Component: GIS | Version: 2.2
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
--------------------------------------------------+------------------------
Hello,
I am trying to create an index for a table with some geodjango fields. The
PostGIS code doesn't take the index name into account, it always generates
one based on table and field name.
Compare
https://github.com/django/django/blob/master/django/contrib/gis/db/backends/postgis/schema.py#L38
with
https://github.com/django/django/blob/master/django/db/backends/base/schema.py#L967
and it is clear that some logic to determine the name is missing. That
leads to the following result in sqlmigrate:
{{{
--
-- Create index dar_navngivenvej_historik_vvnl on field(s)
vejnavnebeliggenhed_vejnavnelinje of model darnavngivenvejhistorik
--
CREATE INDEX
"dawarepl_dar_navngivenvej_historik_vejnavnebeliggenhed_vejnavnelinje_id"
ON "dawarepl_dar_navngivenvej_historik"USING GIST
("vejnavnebeliggenhed_vejnavnelinje");
--
-- Create index dar_navngivenvej_historik_vvno on field(s)
vejnavnebeliggenhed_vejnavneområde of model darnavngivenvejhistorik
--
CREATE INDEX
"dawarepl_dar_navngivenvej_historik_vejnavnebeliggenhed_vejnavneområde_id"
ON "dawarepl_dar_navngivenvej_historik"USING GIST
("vejnavnebeliggenhed_vejnavneområde");
--
-- Create index dar_navngivenvej_historik_vvtp on field(s)
vejnavnebeliggenhed_vejtilslutningspunkter of model
darnavngivenvejhistorik
--
CREATE INDEX
"dawarepl_dar_navngivenvej_historik_vejnavnebeliggenhed_vejtilslutningspunkter_id"
ON "dawarepl_dar_navngivenvej_historik"USING GIST
("vejnavnebeliggenhed_vejtilslutningspunkter");
--
}}}
In case it isn't clear, the index names in the SQL comment are "mine" from
the Meta: section of the model, but the index names used in the actual SQL
are the much longer autogenerated ones.
I believe this should be fixed with a construct like
https://github.com/django/django/blob/master/django/db/backends/base/schema.py#L967
so autogenerated names are only used when 'name' not in kwargs.
--
Ticket URL: <https://code.djangoproject.com/ticket/30846>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/050.eee5315e0bb39267976dbeaa34b04dd9%40djangoproject.com.